annotate libmpcodecs/vd_dmo.c @ 35436:d3b0d3f62d6f

Cosmetic: Reindent.
author upsuper
date Fri, 30 Nov 2012 13:07:39 +0000
parents 277ec491a8a7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
30636
93379281129d Add malloc.h #include for memalign(), fixes the warning:
diego
parents: 30606
diff changeset
19 #include "config.h"
93379281129d Add malloc.h #include for memalign(), fixes the warning:
diego
parents: 30606
diff changeset
20
93379281129d Add malloc.h #include for memalign(), fixes the warning:
diego
parents: 30606
diff changeset
21 #if HAVE_MALLOC_H
93379281129d Add malloc.h #include for memalign(), fixes the warning:
diego
parents: 30606
diff changeset
22 #include <malloc.h>
93379281129d Add malloc.h #include for memalign(), fixes the warning:
diego
parents: 30606
diff changeset
23 #endif
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
24 #include <stdio.h>
cd02bf201f38 DMO support
arpi
parents:
diff changeset
25 #include <stdlib.h>
cd02bf201f38 DMO support
arpi
parents:
diff changeset
26 #include <stdarg.h>
cd02bf201f38 DMO support
arpi
parents:
diff changeset
27
cd02bf201f38 DMO support
arpi
parents:
diff changeset
28 #include "mp_msg.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
29 #include "help_mp.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
30
cd02bf201f38 DMO support
arpi
parents:
diff changeset
31 #include "vd_internal.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
32
cd02bf201f38 DMO support
arpi
parents:
diff changeset
33 #include "loader/dmo/DMO_VideoDecoder.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
34
30504
cc27da5d7286 Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents: 30421
diff changeset
35 static const vd_info_t info = {
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
36 "DMO video codecs",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
37 "dmo",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
38 "A'rpi",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
39 "based on http://avifile.sf.net",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
40 "win32 codecs"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
41 };
cd02bf201f38 DMO support
arpi
parents:
diff changeset
42
cd02bf201f38 DMO support
arpi
parents:
diff changeset
43 LIBVD_EXTERN(dmo)
cd02bf201f38 DMO support
arpi
parents:
diff changeset
44
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
45 struct context {
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
46 void *decoder;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
47 uint8_t *buffer;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
48 int stride;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
49 };
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
50
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
51 // to set/get/query special features/parameters
cd02bf201f38 DMO support
arpi
parents:
diff changeset
52 static int control(sh_video_t *sh,int cmd,void* arg,...){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
53 return CONTROL_UNKNOWN;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
54 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
55
cd02bf201f38 DMO support
arpi
parents:
diff changeset
56 // init driver
cd02bf201f38 DMO support
arpi
parents:
diff changeset
57 static int init(sh_video_t *sh){
30782
1c38d10731ab Partially revert r30645, the final output format is determined by
reimar
parents: 30636
diff changeset
58 unsigned int out_fmt=sh->codec->outfmt[0];
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
59 struct context *ctx;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
60 void *decoder;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
61 if(!(decoder=DMO_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
62 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
63 mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage);
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
64 return 0;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
65 }
30603
c5d8b7640b7d Call mpcodecs_config_vo with the proper image format for dmo and dshow codecs.
reimar
parents: 30504
diff changeset
66 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,out_fmt)) return 0;
30782
1c38d10731ab Partially revert r30645, the final output format is determined by
reimar
parents: 30636
diff changeset
67 // mpcodecs_config_vo can change the format
1c38d10731ab Partially revert r30645, the final output format is determined by
reimar
parents: 30636
diff changeset
68 out_fmt=sh->codec->outfmt[sh->outfmtidx];
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
69 sh->context = ctx = calloc(1, sizeof(*ctx));
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
70 ctx->decoder = decoder;
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
71 switch(out_fmt){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
72 case IMGFMT_YUY2:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
73 case IMGFMT_UYVY:
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
74 DMO_VideoDecoder_SetDestFmt(ctx->decoder,16,out_fmt);break; // packed YUV
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
75 case IMGFMT_YV12:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
76 case IMGFMT_I420:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
77 case IMGFMT_IYUV:
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
78 DMO_VideoDecoder_SetDestFmt(ctx->decoder,12,out_fmt);break; // planar YUV
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
79 case IMGFMT_YVU9:
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
80 DMO_VideoDecoder_SetDestFmt(ctx->decoder,9,out_fmt);break;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
81 case IMGFMT_RGB24:
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
82 case IMGFMT_BGR24:
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
83 if (sh->disp_w & 3)
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
84 {
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
85 ctx->stride = ((sh->disp_w * 3) + 3) & ~3;
31003
00825525514e Replace memalign(x) (x > 8) by av_malloc() to prevent crashes on systems
zuxy
parents: 30782
diff changeset
86 ctx->buffer = av_malloc(ctx->stride * sh->disp_h);
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
87 }
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
88 default:
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
89 DMO_VideoDecoder_SetDestFmt(ctx->decoder,out_fmt&255,0); // RGB/BGR
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
90 }
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
91 DMO_VideoDecoder_StartInternal(ctx->decoder);
33827
277ec491a8a7 Do not translate console messages of verbosity level MSGL_V and above.
diego
parents: 31003
diff changeset
92 mp_msg(MSGT_DECVIDEO, MSGL_V, "INFO: Win32/DMO video codec init OK.\n");
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
93 return 1;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
94 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
95
cd02bf201f38 DMO support
arpi
parents:
diff changeset
96 // uninit driver
cd02bf201f38 DMO support
arpi
parents:
diff changeset
97 static void uninit(sh_video_t *sh){
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
98 struct context *ctx = sh->context;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
99 DMO_VideoDecoder_Destroy(ctx->decoder);
31003
00825525514e Replace memalign(x) (x > 8) by av_malloc() to prevent crashes on systems
zuxy
parents: 30782
diff changeset
100 av_free(ctx->buffer);
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
101 free(ctx);
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
102 sh->context = NULL;
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
103 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
104
cd02bf201f38 DMO support
arpi
parents:
diff changeset
105 //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
106
cd02bf201f38 DMO support
arpi
parents:
diff changeset
107 // decode a frame
cd02bf201f38 DMO support
arpi
parents:
diff changeset
108 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
109 struct context *ctx = sh->context;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
110 uint8_t *buffer = ctx->buffer;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
111 int type = ctx->buffer ? MP_IMGTYPE_EXPORT : MP_IMGTYPE_TEMP;
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
112 mp_image_t* mpi;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
113 if(len<=0) return NULL; // skipped frame
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 18765
diff changeset
114
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
115 if(flags&3){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
116 // framedrop:
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
117 DMO_VideoDecoder_DecodeInternal(ctx->decoder, data, len, 0, 0);
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
118 return NULL;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
119 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 18765
diff changeset
120
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
121 mpi=mpcodecs_get_image(sh, type, MP_IMGFLAG_COMMON_PLANE,
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
122 sh->disp_w, sh->disp_h);
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
123 if (buffer) {
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
124 mpi->planes[0] = buffer;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
125 mpi->stride[0] = ctx->stride;
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
126 } else {
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
127 buffer = mpi->planes[0];
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
128 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 18765
diff changeset
129
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
130 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
131 mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec);
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
132 return NULL;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
133 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
134
30606
caaa73737ef1 DirectShow requires stride to be a multiple of 4 for RGB24/BGR24, add
reimar
parents: 30605
diff changeset
135 DMO_VideoDecoder_DecodeInternal(ctx->decoder, data, len, 1, buffer);
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
136
cd02bf201f38 DMO support
arpi
parents:
diff changeset
137 return mpi;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
138 }