annotate dll_init.c @ 6905:e32d3d0d8998

- fix playlist2dvd bug - change playlist selection mode
author pontscho
date Sun, 04 Aug 2002 20:44:21 +0000
parents 561de0125a61
children b1397d95471f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2775
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2714
diff changeset
1
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2714
diff changeset
2 #include "config.h"
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
3
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
4 #include <stdio.h>
2775
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2714
diff changeset
5 #ifdef HAVE_MALLOC_H
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2714
diff changeset
6 #include <malloc.h>
8e3875816f6d added missing #include <malloc.h>
pl
parents: 2714
diff changeset
7 #endif
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
8 #include <stdlib.h>
1430
1728d249c783 missing unistd.h (requires for off_t under freebsd)
arpi
parents: 1407
diff changeset
9 #include <unistd.h>
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
10
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
11 #include "mp_msg.h"
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1653
diff changeset
12 #include "help_mp.h"
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
13
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
14 #include "stream.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
15 #include "demuxer.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
16
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
17 #include "loader.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
18 //#include "wine/mmreg.h"
1309
598e3047ce13 Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents: 1297
diff changeset
19 #include "wine/vfw.h"
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
20 #include "wine/avifmt.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
21
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
22 #include "codec-cfg.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
23 #include "stheader.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
24
2049
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
25 #include "dll_init.h"
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
26
2897
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 2885
diff changeset
27 #ifdef USE_LIBVO2
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 2885
diff changeset
28 #include "libvo2/img_format.h"
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 2885
diff changeset
29 #else
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
30 #include "libvo/img_format.h"
2897
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 2885
diff changeset
31 #endif
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
32 #include "linux/shmem.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
33
2087
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
34 extern int divx_quality;
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
35
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 // ACM audio and VfW video codecs initialization
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 // based on the avifile library [http://divx.euro.ru]
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
39 int init_acm_audio_codec(sh_audio_t *sh_audio){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 HRESULT ret;
432
5251b0c57e39 sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents: 414
diff changeset
41 WAVEFORMATEX *in_fmt=sh_audio->wf;
3725
ba98028ddc27 fixes warnings
pl
parents: 3437
diff changeset
42 unsigned int srcsize=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
44 mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (ACM) AUDIO Codec init =======\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
46 sh_audio->srcstream=NULL;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
48 sh_audio->o_wf.nChannels=in_fmt->nChannels;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
49 sh_audio->o_wf.nSamplesPerSec=in_fmt->nSamplesPerSec;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
50 sh_audio->o_wf.nAvgBytesPerSec=2*sh_audio->o_wf.nSamplesPerSec*sh_audio->o_wf.nChannels;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
51 sh_audio->o_wf.wFormatTag=WAVE_FORMAT_PCM;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
52 sh_audio->o_wf.nBlockAlign=2*in_fmt->nChannels;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
53 sh_audio->o_wf.wBitsPerSample=16;
3437
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
54 // sh_audio->o_wf.wBitsPerSample=in_fmt->wBitsPerSample;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
55 sh_audio->o_wf.cbSize=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56
3437
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
57 if(verbose) {
6526
561de0125a61 yvu9 and if09 support
alex
parents: 5760
diff changeset
58 #if 1
3437
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
59 printf("Input format:\n");
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
60 printf(" wFormatTag %d\n", in_fmt->wFormatTag);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
61 printf(" nChannels %d\n", in_fmt->nChannels);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
62 printf(" nSamplesPerSec %ld\n", in_fmt->nSamplesPerSec);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
63 printf(" nAvgBytesPerSec %d\n", in_fmt->nAvgBytesPerSec);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
64 printf(" nBlockAlign %d\n", in_fmt->nBlockAlign);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
65 printf(" wBitsPerSample %d\n", in_fmt->wBitsPerSample);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
66 printf(" cbSize %d\n", in_fmt->cbSize);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
67 printf("Output fmt:\n");
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
68 printf(" wFormatTag %d\n", sh_audio->o_wf.wFormatTag);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
69 printf(" nChannels %d\n", sh_audio->o_wf.nChannels);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
70 printf(" nSamplesPerSec %ld\n", sh_audio->o_wf.nSamplesPerSec);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
71 printf(" nAvgBytesPerSec %d\n", sh_audio->o_wf.nAvgBytesPerSec);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
72 printf(" nBlockAlign %d\n", sh_audio->o_wf.nBlockAlign);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
73 printf(" wBitsPerSample %d\n", sh_audio->o_wf.wBitsPerSample);
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
74 printf(" cbSize %d\n", sh_audio->o_wf.cbSize);
5760
41ad1efb8ffb using print_wav_header in acm init
alex
parents: 5554
diff changeset
75 #else
41ad1efb8ffb using print_wav_header in acm init
alex
parents: 5554
diff changeset
76 printf("Input format:\n");
41ad1efb8ffb using print_wav_header in acm init
alex
parents: 5554
diff changeset
77 print_wave_header(in_fmt);
6526
561de0125a61 yvu9 and if09 support
alex
parents: 5760
diff changeset
78 print_wave_header(sh_audio->wf);
5760
41ad1efb8ffb using print_wav_header in acm init
alex
parents: 5554
diff changeset
79 printf("Output fmt:\n");
41ad1efb8ffb using print_wav_header in acm init
alex
parents: 5554
diff changeset
80 print_wave_header(&sh_audio->o_wf);
41ad1efb8ffb using print_wav_header in acm init
alex
parents: 5554
diff changeset
81 printf("\n");
41ad1efb8ffb using print_wav_header in acm init
alex
parents: 5554
diff changeset
82 #endif
3437
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
83 }
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
84
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
85
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
86 win32_codec_name = sh_audio->codec->dll;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
87 ret=acmStreamOpen(&sh_audio->srcstream,(HACMDRIVER)NULL,
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
88 in_fmt,&sh_audio->o_wf,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 NULL,0,0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 if(ret){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 if(ret==ACMERR_NOTPOSSIBLE)
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
92 mp_msg(MSGT_WIN32,MSGL_ERR,"ACM_Decoder: Unappropriate audio format\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 else
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1653
diff changeset
94 mp_msg(MSGT_WIN32,MSGL_ERR,"ACM_Decoder: acmStreamOpen error: %d", (int)ret);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
95 sh_audio->srcstream=NULL;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 }
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
98 mp_msg(MSGT_WIN32,MSGL_V,"Audio codec opened OK! ;-)\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99
631
1e6e08593762 ACM fixes - now plays april_25.asf too
arpi_esp
parents: 603
diff changeset
100 acmStreamSize(sh_audio->srcstream, in_fmt->nBlockAlign, &srcsize, ACM_STREAMSIZEF_SOURCE);
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
101 //if(verbose) printf("Audio ACM output buffer min. size: %ld (reported by codec)\n",srcsize);
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 714
diff changeset
102 srcsize*=2;
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
103 //if(srcsize<MAX_OUTBURST) srcsize=MAX_OUTBURST;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
104 if(!srcsize){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
105 mp_msg(MSGT_WIN32,MSGL_WARN,"Warning! ACM codec reports srcsize=0\n");
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
106 srcsize=16384;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
107 }
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
108 // limit srcsize to 4-16kb
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
109 //while(srcsize && srcsize<4096) srcsize*=2;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
110 //while(srcsize>16384) srcsize/=2;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
111 sh_audio->audio_out_minsize=srcsize; // audio output min. size
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
112 mp_msg(MSGT_WIN32,MSGL_V,"Audio ACM output buffer min. size: %ld\n",srcsize);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 714
diff changeset
114 acmStreamSize(sh_audio->srcstream, srcsize, &srcsize, ACM_STREAMSIZEF_DESTINATION);
5458
b3d1348b251f audio input buffer allocation/free cleanup
arpi
parents: 5449
diff changeset
115 // if(srcsize<in_fmt->nBlockAlign) srcsize=in_fmt->nBlockAlign;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116
5458
b3d1348b251f audio input buffer allocation/free cleanup
arpi
parents: 5449
diff changeset
117 mp_msg(MSGT_WIN32,MSGL_V,"Audio ACM input buffer min. size: %ld\n",srcsize);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
118
5458
b3d1348b251f audio input buffer allocation/free cleanup
arpi
parents: 5449
diff changeset
119 sh_audio->audio_in_minsize=2*srcsize; // audio input min. size
b3d1348b251f audio input buffer allocation/free cleanup
arpi
parents: 5449
diff changeset
120
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
124 int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int minlen,int maxlen){
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
125 ACMSTREAMHEADER ash;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
126 HRESULT hr;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
127 DWORD srcsize=0;
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
128 DWORD len=minlen;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
129 acmStreamSize(sh_audio->srcstream,len , &srcsize, ACM_STREAMSIZEF_DESTINATION);
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
130 mp_msg(MSGT_WIN32,MSGL_DBG3,"acm says: srcsize=%ld (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,len);
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
131
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
132 if(srcsize<sh_audio->wf->nBlockAlign){
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
133 srcsize=sh_audio->wf->nBlockAlign;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
134 acmStreamSize(sh_audio->srcstream, srcsize, &len, ACM_STREAMSIZEF_SOURCE);
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
135 if(len>maxlen) len=maxlen;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
136 }
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
137
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
138 // if(srcsize==0) srcsize=((WAVEFORMATEX *)&sh_audio->o_wf_ext)->nBlockAlign;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
139 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!!
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
140 if(sh_audio->a_in_buffer_len<srcsize){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
141 sh_audio->a_in_buffer_len+=
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
142 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len],
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
143 srcsize-sh_audio->a_in_buffer_len);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
144 }
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
145 mp_msg(MSGT_WIN32,MSGL_DBG3,"acm convert %d -> %d bytes\n",sh_audio->a_in_buffer_len,len);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
146 memset(&ash, 0, sizeof(ash));
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
147 ash.cbStruct=sizeof(ash);
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
148 ash.fdwStatus=0;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
149 ash.dwUser=0;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
150 ash.pbSrc=sh_audio->a_in_buffer;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
151 ash.cbSrcLength=sh_audio->a_in_buffer_len;
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
152 ash.pbDst=a_buffer;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
153 ash.cbDstLength=len;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
154 hr=acmStreamPrepareHeader(sh_audio->srcstream,&ash,0);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
155 if(hr){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
156 mp_msg(MSGT_WIN32,MSGL_V,"ACM_Decoder: acmStreamPrepareHeader error %d\n",(int)hr);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
157 return -1;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
158 }
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
159 hr=acmStreamConvert(sh_audio->srcstream,&ash,0);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
160 if(hr){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
161 mp_msg(MSGT_WIN32,MSGL_DBG2,"ACM_Decoder: acmStreamConvert error %d\n",(int)hr);
3437
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
162 switch(hr)
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
163 {
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
164 case ACMERR_NOTPOSSIBLE:
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
165 case ACMERR_UNPREPARED:
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
166 mp_msg(MSGT_WIN32, MSGL_DBG2, "ACM_Decoder: acmStreamConvert error: probarly not initialized!\n");
ae0e2736a5d4 added in/out format debug to acm init like in vfw init (for testing vivo decoder dll :)
alex
parents: 2897
diff changeset
167 }
631
1e6e08593762 ACM fixes - now plays april_25.asf too
arpi_esp
parents: 603
diff changeset
168 // return -1;
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
169 }
1407
2e23a033d6f8 acm convert message verbose1->2
arpi
parents: 1309
diff changeset
170 if(verbose>1)
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
171 mp_msg(MSGT_WIN32,MSGL_DBG2,"acm converted %d -> %d\n",ash.cbSrcLengthUsed,ash.cbDstLengthUsed);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
172 if(ash.cbSrcLengthUsed>=sh_audio->a_in_buffer_len){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
173 sh_audio->a_in_buffer_len=0;
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
174 } else {
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
175 sh_audio->a_in_buffer_len-=ash.cbSrcLengthUsed;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
176 memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[ash.cbSrcLengthUsed],sh_audio->a_in_buffer_len);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
177 }
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
178 len=ash.cbDstLengthUsed;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
179 hr=acmStreamUnprepareHeader(sh_audio->srcstream,&ash,0);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
180 if(hr){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
181 mp_msg(MSGT_WIN32,MSGL_V,"ACM_Decoder: acmStreamUnprepareHeader error %d\n",(int)hr);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
182 }
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
183 return len;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
184 }
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
185
5449
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
186 int close_acm_audio_codec(sh_audio_t *sh_audio)
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
187 {
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
188 HRESULT ret;
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
189
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
190 ret = acmStreamClose(sh_audio->srcstream, 0);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
191
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
192 if (ret)
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
193 switch(ret)
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
194 {
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
195 case ACMERR_BUSY:
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
196 case ACMERR_CANCELED:
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
197 mp_msg(MSGT_WIN32, MSGL_DBG2, "ACM_Decoder: stream busy, waiting..\n");
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
198 sleep(100);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
199 return(close_acm_audio_codec(sh_audio));
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
200 case ACMERR_UNPREPARED:
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
201 case ACMERR_NOTPOSSIBLE:
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
202 return(0);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
203 default:
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
204 mp_msg(MSGT_WIN32, MSGL_WARN, "ACM_Decoder: unknown error occured: %d\n", ret);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
205 return(0);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
206 }
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
207
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
208 // MSACM_UnregisterAllDrivers();
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
209 return(1);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
210 }
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
211
2049
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
212 int init_vfw_video_codec(sh_video_t *sh_video,int ex){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 HRESULT ret;
489
2bb59b7c748a BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents: 469
diff changeset
214 int yuv=0;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
215 unsigned int outfmt=sh_video->codec->outfmt[sh_video->outfmtidx];
2679
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
216 char *temp;
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
217 int temp_len;
2087
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
218 int i;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
220 mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Codec init =======\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
222 memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER));
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
223 sh_video->o_bih.biSize = sizeof(BITMAPINFOHEADER);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
225 win32_codec_name = sh_video->codec->dll;
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 714
diff changeset
226 // sh_video->hic = ICOpen( 0x63646976, sh_video->bih->biCompression, ICMODE_FASTDECOMPRESS);
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 714
diff changeset
227 sh_video->hic = ICOpen( 0x63646976, sh_video->bih->biCompression, ICMODE_DECOMPRESS);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
228 if(!sh_video->hic){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
229 mp_msg(MSGT_WIN32,MSGL_ERR,"ICOpen failed! unknown codec / wrong parameters?\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232
2679
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
233 // sh_video->bih->biBitCount=32;
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
234
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
235 temp_len = ICDecompressGetFormatSize(sh_video->hic, sh_video->bih);
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
236
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
237 if (temp_len < sh_video->o_bih.biSize)
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
238 temp_len = sh_video->o_bih.biSize;
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
239
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
240 temp = malloc(temp_len);
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
241 printf("ICDecompressGetFormatSize ret: %d\n", temp_len);
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
242
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
243 #if 0
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
244 {
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
245 ICINFO icinfo;
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
246 ret = ICGetInfo(sh_video->hic, &icinfo, sizeof(ICINFO));
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
247 printf("%d - %d - %d\n", ret, icinfo.dwSize, sizeof(ICINFO));
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
248 printf("Compressor type: %.4x\n", icinfo.fccType);
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
249 printf("Compressor subtype: %.4x\n", icinfo.fccHandler);
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
250 printf("Compressor flags: %lu, version %lu, ICM version: %lu\n",
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
251 icinfo.dwFlags, icinfo.dwVersion, icinfo.dwVersionICM);
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
252 printf("Compressor name: %s\n", icinfo.szName);
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
253 printf("Compressor description: %s\n", icinfo.szDescription);
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
254
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
255 printf("Flags:");
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
256 if (icinfo.dwFlags & VIDCF_QUALITY)
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
257 printf(" quality");
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
258 if (icinfo.dwFlags & VIDCF_FASTTEMPORALD)
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
259 printf(" fast-decompr");
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
260 if (icinfo.dwFlags & VIDCF_QUALITYTIME)
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
261 printf(" temp-quality");
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
262 printf("\n");
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
263 }
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
264 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265
2087
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
266 // Note: DivX.DLL overwrites 4 bytes _AFTER_ the o_bih header, so it corrupts
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
267 // the sh_video struct content. We call it with an 1024-byte temp space and
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
268 // then copy out the data we need:
2679
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
269 memset(temp,0x77,temp_len);
2885
7459ddb8b539 for pegasus mjpeg
arpi
parents: 2876
diff changeset
270 // memcpy(temp,sh_video->bih,sizeof(BITMAPINFOHEADER));
7459ddb8b539 for pegasus mjpeg
arpi
parents: 2876
diff changeset
271 // sh_video->o_bih.biSize = temp_len;
2087
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
272
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
273 ret = ICDecompressGetFormat(sh_video->hic, sh_video->bih, temp);
2679
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
274 if(ret < 0){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
275 mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormat failed: Error %d\n", (int)ret);
2679
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
276 for (i=0; i < temp_len; i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02x ", temp[i]);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 }
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
279 mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormat OK\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280
2087
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
281 memcpy(&sh_video->o_bih,temp,sizeof(sh_video->o_bih));
2679
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
282
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
283 if (temp_len > sizeof(sh_video->o_bih))
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
284 {
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
285 mp_msg(MSGT_WIN32, MSGL_V, "Extra info in o_bih (%d bytes)!\n",
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
286 temp_len-sizeof(sh_video->o_bih));
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
287 for(i=sizeof(sh_video->o_bih);i<temp_len;i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02X ",temp[i]);
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
288 }
ae59ad941b42 supporting GetFormatSize
alex
parents: 2087
diff changeset
289 free(temp);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 // printf("ICM_DECOMPRESS_QUERY=0x%X",ICM_DECOMPRESS_QUERY);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
292 // sh_video->o_bih.biWidth=sh_video->bih.biWidth;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
293 // sh_video->o_bih.biCompression = 0x32315659; // mmioFOURCC('U','Y','V','Y');
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
294 // ret=ICDecompressGetFormatSize(sh_video->hic,&sh_video->o_bih);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
295 // sh_video->o_bih.biCompression = 3; //0x32315659;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
296 // sh_video->o_bih.biCompression = mmioFOURCC('U','Y','V','Y');
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
297 // sh_video->o_bih.biCompression = mmioFOURCC('U','Y','V','Y');
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
298 // sh_video->o_bih.biCompression = mmioFOURCC('Y','U','Y','2');
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
299 // sh_video->o_bih.biPlanes=3;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
300 // sh_video->o_bih.biBitCount=16;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 631
diff changeset
302 #if 0
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 631
diff changeset
303 // workaround for pegasus MJPEG:
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 631
diff changeset
304 if(!sh_video->o_bih.biWidth) sh_video->o_bih.biWidth=sh_video->bih->biWidth;
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 631
diff changeset
305 if(!sh_video->o_bih.biHeight) sh_video->o_bih.biHeight=sh_video->bih->biHeight;
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 631
diff changeset
306 if(!sh_video->o_bih.biPlanes) sh_video->o_bih.biPlanes=sh_video->bih->biPlanes;
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 631
diff changeset
307 #endif
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
308
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
309 switch (outfmt) {
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
310
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
311 /* planar format */
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
312 case IMGFMT_YV12:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
313 case IMGFMT_I420:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
314 case IMGFMT_IYUV:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
315 sh_video->o_bih.biBitCount=12;
489
2bb59b7c748a BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents: 469
diff changeset
316 yuv=1;
467
e53a9edbee98 fixed yuvhack
arpi_esp
parents: 432
diff changeset
317 break;
6526
561de0125a61 yvu9 and if09 support
alex
parents: 5760
diff changeset
318 case IMGFMT_YVU9:
561de0125a61 yvu9 and if09 support
alex
parents: 5760
diff changeset
319 case IMGFMT_IF09:
561de0125a61 yvu9 and if09 support
alex
parents: 5760
diff changeset
320 sh_video->o_bih.biBitCount=9;
561de0125a61 yvu9 and if09 support
alex
parents: 5760
diff changeset
321 yuv=1;
561de0125a61 yvu9 and if09 support
alex
parents: 5760
diff changeset
322 break;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
324 /* packed format */
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
325 case IMGFMT_YUY2:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
326 case IMGFMT_UYVY:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
327 case IMGFMT_YVYU:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
328 sh_video->o_bih.biBitCount=16;
489
2bb59b7c748a BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents: 469
diff changeset
329 yuv=1;
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
330 break;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
331
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
332 /* rgb/bgr format */
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
333 case IMGFMT_RGB8:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
334 case IMGFMT_BGR8:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
335 sh_video->o_bih.biBitCount=8;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
336 break;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
338 case IMGFMT_RGB15:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
339 case IMGFMT_RGB16:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
340 case IMGFMT_BGR15:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
341 case IMGFMT_BGR16:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
342 sh_video->o_bih.biBitCount=16;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
343 break;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
344
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
345 case IMGFMT_RGB24:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
346 case IMGFMT_BGR24:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
347 sh_video->o_bih.biBitCount=24;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
348 break;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
349
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
350 case IMGFMT_RGB32:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
351 case IMGFMT_BGR32:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
352 sh_video->o_bih.biBitCount=32;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
353 break;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
355 default:
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
356 mp_msg(MSGT_WIN32,MSGL_ERR,"unsupported image format: 0x%x\n", outfmt);
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
357 return 0;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
358 }
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
359
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
360 sh_video->o_bih.biSizeImage = sh_video->o_bih.biWidth * sh_video->o_bih.biHeight * (sh_video->o_bih.biBitCount/8);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 631
diff changeset
361
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
362 if(!(sh_video->codec->outflags[sh_video->outfmtidx]&CODECS_FLAG_FLIP)) {
432
5251b0c57e39 sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents: 414
diff changeset
363 sh_video->o_bih.biHeight=-sh_video->bih->biHeight; // flip image!
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
364 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365
489
2bb59b7c748a BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents: 469
diff changeset
366 if(yuv && !(sh_video->codec->outflags[sh_video->outfmtidx] & CODECS_FLAG_YUVHACK))
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
367 sh_video->o_bih.biCompression = outfmt;
759
34edf774ef73 HuffYUV YUY2->RGB fixed
arpi_esp
parents: 758
diff changeset
368 else
34edf774ef73 HuffYUV YUY2->RGB fixed
arpi_esp
parents: 758
diff changeset
369 sh_video->o_bih.biCompression = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371 if(verbose) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372 printf("Starting decompression, format:\n");
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
373 printf(" biSize %ld\n", sh_video->bih->biSize);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
374 printf(" biWidth %ld\n", sh_video->bih->biWidth);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
375 printf(" biHeight %ld\n", sh_video->bih->biHeight);
432
5251b0c57e39 sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents: 414
diff changeset
376 printf(" biPlanes %d\n", sh_video->bih->biPlanes);
5251b0c57e39 sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents: 414
diff changeset
377 printf(" biBitCount %d\n", sh_video->bih->biBitCount);
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
378 printf(" biCompression 0x%lx ('%.4s')\n", sh_video->bih->biCompression, (char *)&sh_video->bih->biCompression);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
379 printf(" biSizeImage %ld\n", sh_video->bih->biSizeImage);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380 printf("Dest fmt:\n");
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
381 printf(" biSize %ld\n", sh_video->o_bih.biSize);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
382 printf(" biWidth %ld\n", sh_video->o_bih.biWidth);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
383 printf(" biHeight %ld\n", sh_video->o_bih.biHeight);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
384 printf(" biPlanes %d\n", sh_video->o_bih.biPlanes);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
385 printf(" biBitCount %d\n", sh_video->o_bih.biBitCount);
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
386 printf(" biCompression 0x%lx ('%.4s')\n", sh_video->o_bih.biCompression, (char *)&sh_video->o_bih.biCompression);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
387 printf(" biSizeImage %ld\n", sh_video->o_bih.biSizeImage);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389
1297
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
390 ret = ex ?
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
391 ICDecompressQueryEx(sh_video->hic, sh_video->bih, &sh_video->o_bih) :
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
392 ICDecompressQuery(sh_video->hic, sh_video->bih, &sh_video->o_bih);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 if(ret){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
394 mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressQuery failed: Error %d\n", (int)ret);
2714
3615abd17375 ignoring decompressquery error
arpi
parents: 2679
diff changeset
395 // return 0;
3615abd17375 ignoring decompressquery error
arpi
parents: 2679
diff changeset
396 } else
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
397 mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressQuery OK\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398
1297
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
399 ret = ex ?
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
400 ICDecompressBeginEx(sh_video->hic, sh_video->bih, &sh_video->o_bih) :
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
401 ICDecompressBegin(sh_video->hic, sh_video->bih, &sh_video->o_bih);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402 if(ret){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
403 mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressBegin failed: Error %d\n", (int)ret);
2876
12a0be665dfd m3jpg support - ignore error
arpi
parents: 2775
diff changeset
404 // return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406
2049
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
407 sh_video->our_out_buffer = (char*)memalign(64,sh_video->o_bih.biSizeImage);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
408 if(!sh_video->our_out_buffer){
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1653
diff changeset
409 mp_msg(MSGT_WIN32,MSGL_ERR,MSGTR_NoMemForDecodedImage, sh_video->o_bih.biSizeImage);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412
489
2bb59b7c748a BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents: 469
diff changeset
413 if(yuv && sh_video->codec->outflags[sh_video->outfmtidx] & CODECS_FLAG_YUVHACK)
469
434889ca2340 ehh typo...
arpi_esp
parents: 467
diff changeset
414 sh_video->o_bih.biCompression = outfmt;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 // avi_header.our_in_buffer=malloc(avi_header.video.dwSuggestedBufferSize); // FIXME!!!!
2087
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
417
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
418 ICSendMessage(sh_video->hic, ICM_USER+80, (long)(&divx_quality) ,NULL);
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
419
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1430
diff changeset
420 mp_msg(MSGT_WIN32,MSGL_V,"VIDEO CODEC Init OK!!! ;-)\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 }
2049
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
423
2087
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
424 int vfw_set_postproc(sh_video_t* sh_video,int quality){
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
425 // Works only with opendivx/divx4 based DLL
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
426 return ICSendMessage(sh_video->hic, ICM_USER+80, (long)(&quality) ,NULL);
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
427 }
fbf7ce9401ff divx.dll o_bih workaround, postprocessing support
arpi
parents: 2049
diff changeset
428
2049
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
429 int vfw_decode_video(sh_video_t* sh_video,void* start,int in_size,int drop_frame,int ex){
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
430 HRESULT ret;
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
431
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
432 sh_video->bih->biSizeImage = in_size;
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
433
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
434 if(ex)
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
435 ret = ICDecompressEx(sh_video->hic,
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
436 ( (sh_video->ds->flags&1) ? 0 : ICDECOMPRESS_NOTKEYFRAME ) |
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
437 ( (drop_frame==2 && !(sh_video->ds->flags&1))?(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL):0 ) ,
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
438 sh_video->bih, start,
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
439 &sh_video->o_bih,
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
440 drop_frame ? 0 : sh_video->our_out_buffer);
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
441 else
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
442 ret = ICDecompress(sh_video->hic,
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
443 ( (sh_video->ds->flags&1) ? 0 : ICDECOMPRESS_NOTKEYFRAME ) |
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
444 ( (drop_frame==2 && !(sh_video->ds->flags&1))?(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL):0 ) ,
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
445 sh_video->bih, start,
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
446 &sh_video->o_bih,
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
447 drop_frame ? 0 : sh_video->our_out_buffer);
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
448
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
449 return (int)ret;
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
450 }
df41903fd7d7 VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents: 1973
diff changeset
451
5449
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
452 int vfw_close_video_codec(sh_video_t *sh_video, int ex)
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
453 {
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
454 HRESULT ret;
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
455
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
456 ret = ICDecompressEnd(sh_video->hic);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
457 if (ret)
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
458 {
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
459 mp_msg(MSGT_WIN32, MSGL_WARN, "ICDecompressEnd failed: %d\n", ret);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
460 return(0);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
461 }
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
462
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
463 ret = ICClose(sh_video->hic);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
464 if (ret)
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
465 {
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
466 mp_msg(MSGT_WIN32, MSGL_WARN, "ICClose failed: %d\n", ret);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
467 return(0);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
468 }
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
469
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
470 return(1);
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
471 }
c13dba5b224e added vfw and acm uninit
alex
parents: 4638
diff changeset
472
4574
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
473 /************************ VFW COMPRESSION *****************************/
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
474
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
475 static int encoder_hic=0;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
476 static void* encoder_buf=NULL;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
477 static int encoder_buf_size=0;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
478 static int encoder_frameno=0;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
479
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
480 //int init_vfw_encoder(char *dll_name, BITMAPINFOHEADER *input_bih, BITMAPINFOHEADER *output_bih)
4638
a4e774e16b22 div3/vfw encoding fixed
arpi
parents: 4574
diff changeset
481 BITMAPINFOHEADER* vfw_open_encoder(char *dll_name, BITMAPINFOHEADER *input_bih,unsigned int out_fourcc)
4574
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
482 {
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
483 HRESULT ret;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
484 BITMAPINFOHEADER* output_bih=NULL;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
485 int temp_len;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
486
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
487 //sh_video = malloc(sizeof(sh_video_t));
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
488
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
489 mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Encoder init =======\n");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
490
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
491 // memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER));
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
492 // output_bih->biSize = sizeof(BITMAPINFOHEADER);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
493
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
494 win32_codec_name = dll_name;
4638
a4e774e16b22 div3/vfw encoding fixed
arpi
parents: 4574
diff changeset
495 encoder_hic = ICOpen( 0x63646976, out_fourcc, ICMODE_COMPRESS);
4574
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
496 if(!encoder_hic){
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
497 mp_msg(MSGT_WIN32,MSGL_ERR,"ICOpen failed! unknown codec / wrong parameters?\n");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
498 return NULL;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
499 }
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
500 printf("HIC: %x\n", encoder_hic);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
501
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
502 #if 1
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
503 {
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
504 ICINFO icinfo;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
505
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
506 ret = ICGetInfo(encoder_hic, &icinfo, sizeof(ICINFO));
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
507 printf("%d - %d - %d\n", ret, icinfo.dwSize, sizeof(ICINFO));
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
508 printf("Compressor type: %.4x\n", icinfo.fccType);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
509 printf("Compressor subtype: %.4x\n", icinfo.fccHandler);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
510 printf("Compressor flags: %lu, version %lu, ICM version: %lu\n",
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
511 icinfo.dwFlags, icinfo.dwVersion, icinfo.dwVersionICM);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
512 //printf("Compressor name: %s\n", icinfo.szName);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
513 //printf("Compressor description: %s\n", icinfo.szDescription);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
514
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
515 printf("Flags:");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
516 if (icinfo.dwFlags & VIDCF_QUALITY)
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
517 printf(" quality");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
518 if (icinfo.dwFlags & VIDCF_FASTTEMPORALD)
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
519 printf(" fast-decompr");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
520 if (icinfo.dwFlags & VIDCF_QUALITYTIME)
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
521 printf(" temp-quality");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
522 printf("\n");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
523 }
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
524 #endif
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
525
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
526 temp_len = ICCompressGetFormatSize(encoder_hic, input_bih);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
527 printf("ICCompressGetFormatSize ret: %d\n", temp_len);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
528
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
529 if (temp_len < sizeof(BITMAPINFOHEADER)) temp_len=sizeof(BITMAPINFOHEADER);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
530
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
531 output_bih = malloc(temp_len+4);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
532 memset(output_bih,0,temp_len);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
533 output_bih->biSize = temp_len; //sizeof(BITMAPINFOHEADER);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
534
5554
1a2d1bdab0b4 vfw encoding func splitted to init and start parts
arpi
parents: 5458
diff changeset
535 return output_bih;
1a2d1bdab0b4 vfw encoding func splitted to init and start parts
arpi
parents: 5458
diff changeset
536 }
1a2d1bdab0b4 vfw encoding func splitted to init and start parts
arpi
parents: 5458
diff changeset
537
1a2d1bdab0b4 vfw encoding func splitted to init and start parts
arpi
parents: 5458
diff changeset
538 int vfw_start_encoder(BITMAPINFOHEADER *input_bih, BITMAPINFOHEADER *output_bih){
1a2d1bdab0b4 vfw encoding func splitted to init and start parts
arpi
parents: 5458
diff changeset
539 HRESULT ret;
1a2d1bdab0b4 vfw encoding func splitted to init and start parts
arpi
parents: 5458
diff changeset
540 int temp_len=output_bih->biSize;
1a2d1bdab0b4 vfw encoding func splitted to init and start parts
arpi
parents: 5458
diff changeset
541 int i;
1a2d1bdab0b4 vfw encoding func splitted to init and start parts
arpi
parents: 5458
diff changeset
542
4574
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
543 ret = ICCompressGetFormat(encoder_hic, input_bih, output_bih);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
544 if(ret < 0){
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
545 unsigned char* temp=output_bih;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
546 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressGetFormat failed: Error %d (0x%X)\n", (int)ret, (int)ret);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
547 for (i=0; i < temp_len; i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02x ", temp[i]);
5554
1a2d1bdab0b4 vfw encoding func splitted to init and start parts
arpi
parents: 5458
diff changeset
548 return 0;
4574
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
549 }
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
550 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressGetFormat OK\n");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
551
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
552 if (temp_len > sizeof(BITMAPINFOHEADER))
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
553 {
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
554 unsigned char* temp=output_bih;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
555 mp_msg(MSGT_WIN32, MSGL_V, "Extra info in o_bih (%d bytes)!\n",
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
556 temp_len-sizeof(BITMAPINFOHEADER));
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
557 for(i=sizeof(output_bih);i<temp_len;i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02X ",temp[i]);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
558 }
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
559
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
560 // if(verbose) {
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
561 printf("Starting compression:\n");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
562 printf(" Input format:\n");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
563 printf(" biSize %ld\n", input_bih->biSize);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
564 printf(" biWidth %ld\n", input_bih->biWidth);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
565 printf(" biHeight %ld\n", input_bih->biHeight);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
566 printf(" biPlanes %d\n", input_bih->biPlanes);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
567 printf(" biBitCount %d\n", input_bih->biBitCount);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
568 printf(" biCompression 0x%lx ('%.4s')\n", input_bih->biCompression, (char *)&input_bih->biCompression);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
569 printf(" biSizeImage %ld\n", input_bih->biSizeImage);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
570 printf(" Output format:\n");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
571 printf(" biSize %ld\n", output_bih->biSize);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
572 printf(" biWidth %ld\n", output_bih->biWidth);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
573 printf(" biHeight %ld\n", output_bih->biHeight);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
574 printf(" biPlanes %d\n", output_bih->biPlanes);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
575 printf(" biBitCount %d\n", output_bih->biBitCount);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
576 printf(" biCompression 0x%lx ('%.4s')\n", output_bih->biCompression, (char *)&output_bih->biCompression);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
577 printf(" biSizeImage %ld\n", output_bih->biSizeImage);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
578 // }
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
579
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
580 output_bih->biWidth=input_bih->biWidth;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
581 output_bih->biHeight=input_bih->biHeight;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
582
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
583 ret = ICCompressQuery(encoder_hic, input_bih, output_bih);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
584 if(ret){
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
585 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressQuery failed: Error %d\n", (int)ret);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
586 return 0;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
587 } else
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
588 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressQuery OK\n");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
589
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
590 ret = ICCompressBegin(encoder_hic, input_bih, output_bih);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
591 if(ret){
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
592 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressBegin failed: Error %d\n", (int)ret);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
593 // return 0;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
594 } else
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
595 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressBegin OK\n");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
596
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
597 printf(" Output format after query/begin:\n");
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
598 printf(" biSize %ld\n", output_bih->biSize);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
599 printf(" biWidth %ld\n", output_bih->biWidth);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
600 printf(" biHeight %ld\n", output_bih->biHeight);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
601 printf(" biPlanes %d\n", output_bih->biPlanes);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
602 printf(" biBitCount %d\n", output_bih->biBitCount);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
603 printf(" biCompression 0x%lx ('%.4s')\n", output_bih->biCompression, (char *)&output_bih->biCompression);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
604 printf(" biSizeImage %ld\n", output_bih->biSizeImage);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
605
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
606 encoder_buf_size=input_bih->biSizeImage;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
607 encoder_buf=malloc(encoder_buf_size);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
608 encoder_frameno=0;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
609
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
610 mp_msg(MSGT_WIN32,MSGL_V,"VIDEO CODEC Init OK!!! ;-)\n");
5554
1a2d1bdab0b4 vfw encoding func splitted to init and start parts
arpi
parents: 5458
diff changeset
611 return 1;
4574
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
612 }
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
613
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
614 int vfw_encode_frame(BITMAPINFOHEADER* biOutput,void* OutBuf,
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
615 BITMAPINFOHEADER* biInput,void* Image,
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
616 long* keyframe, int quality){
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
617 HRESULT ret;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
618
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
619 //long VFWAPIV ICCompress(
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
620 // HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpOutputBuf,
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
621 // LPBITMAPINFOHEADER lpbiInput,void* lpImage,long* lpckid,
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
622 // long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality,
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
623 // LPBITMAPINFOHEADER lpbiInputPrev,void* lpImagePrev
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
624 //);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
625
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
626 // printf("vfw_encode_frame(%p,%p, %p,%p, %p,%d)\n",biOutput,OutBuf,biInput,Image,keyframe,quality);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
627
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
628 ret=ICCompress(encoder_hic, 0,
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
629 biOutput, OutBuf,
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
630 biInput, Image,
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
631 NULL, keyframe, encoder_frameno, 0, quality,
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
632 biInput, encoder_buf);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
633
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
634 // printf("ok. size=%d\n",biOutput->biSizeImage);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
635
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
636 memcpy(encoder_buf,Image,encoder_buf_size);
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
637 ++encoder_frameno;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
638
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
639 return (int)ret;
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
640 }
683a0585420c VfW encoding support
arpi
parents: 3725
diff changeset
641