annotate dll_init.c @ 1475:1a4c9a7e9b67

Applied vladimirs freebsd patch (largefile default on freebsd and misc)
author atmos4
date Thu, 09 Aug 2001 22:10:17 +0000
parents 1728d249c783
children 5c7760aa4f94
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
1
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
2 #include <stdio.h>
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
3 #include <stdlib.h>
1430
1728d249c783 missing unistd.h (requires for off_t under freebsd)
arpi
parents: 1407
diff changeset
4 #include <unistd.h>
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
5
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
6 #include "config.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
7
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
8 extern int verbose; // defined in mplayer.c
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
9
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
10 #include "stream.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
11 #include "demuxer.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
12
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
13 #include "loader.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
14 //#include "wine/mmreg.h"
1309
598e3047ce13 Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents: 1297
diff changeset
15 #include "wine/vfw.h"
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
16 #include "wine/avifmt.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
17
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
18 #include "codec-cfg.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
19 #include "stheader.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
20
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
21 #include "libvo/img_format.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
22 #include "linux/shmem.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
23
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
24 extern char* win32_codec_name; // must be set before calling DrvOpen() !!!
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 489
diff changeset
25
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 // ACM audio and VfW video codecs initialization
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 // based on the avifile library [http://divx.euro.ru]
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
29 int init_acm_audio_codec(sh_audio_t *sh_audio){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 HRESULT ret;
432
5251b0c57e39 sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents: 414
diff changeset
31 WAVEFORMATEX *in_fmt=sh_audio->wf;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 unsigned long srcsize=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 if(verbose) printf("======= Win32 (ACM) AUDIO Codec init =======\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
36 sh_audio->srcstream=NULL;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 // if(in_fmt->nSamplesPerSec==0){ printf("Bad WAVE header!\n");exit(1); }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 // MSACM_RegisterAllDrivers();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
41 sh_audio->o_wf.nChannels=in_fmt->nChannels;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
42 sh_audio->o_wf.nSamplesPerSec=in_fmt->nSamplesPerSec;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
43 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
44 sh_audio->o_wf.wFormatTag=WAVE_FORMAT_PCM;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
45 sh_audio->o_wf.nBlockAlign=2*in_fmt->nChannels;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
46 sh_audio->o_wf.wBitsPerSample=16;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
47 sh_audio->o_wf.cbSize=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
49 win32_codec_name = sh_audio->codec->dll;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
50 ret=acmStreamOpen(&sh_audio->srcstream,(HACMDRIVER)NULL,
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
51 in_fmt,&sh_audio->o_wf,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 NULL,0,0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 if(ret){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 if(ret==ACMERR_NOTPOSSIBLE)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 printf("ACM_Decoder: Unappropriate audio format\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 else
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
57 printf("ACM_Decoder: acmStreamOpen error %d", (int)ret);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
58 sh_audio->srcstream=NULL;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 if(verbose) printf("Audio codec opened OK! ;-)\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62
631
1e6e08593762 ACM fixes - now plays april_25.asf too
arpi_esp
parents: 603
diff changeset
63 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
64 //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
65 srcsize*=2;
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
66 //if(srcsize<MAX_OUTBURST) srcsize=MAX_OUTBURST;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
67 if(!srcsize){
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
68 printf("Warning! ACM codec reports srcsize=0\n");
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
69 srcsize=16384;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
70 }
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
71 // limit srcsize to 4-16kb
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
72 //while(srcsize && srcsize<4096) srcsize*=2;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
73 //while(srcsize>16384) srcsize/=2;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
74 sh_audio->audio_out_minsize=srcsize; // audio output min. size
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
75 if(verbose) printf("Audio ACM output buffer min. size: %ld\n",srcsize);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 714
diff changeset
77 acmStreamSize(sh_audio->srcstream, srcsize, &srcsize, ACM_STREAMSIZEF_DESTINATION);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
78 sh_audio->audio_in_minsize=srcsize; // audio input min. size
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
79 if(verbose) printf("Audio ACM input buffer min. size: %ld\n",srcsize);
631
1e6e08593762 ACM fixes - now plays april_25.asf too
arpi_esp
parents: 603
diff changeset
80
1e6e08593762 ACM fixes - now plays april_25.asf too
arpi_esp
parents: 603
diff changeset
81 if(srcsize<in_fmt->nBlockAlign) srcsize=in_fmt->nBlockAlign;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82
631
1e6e08593762 ACM fixes - now plays april_25.asf too
arpi_esp
parents: 603
diff changeset
83 sh_audio->a_in_buffer_size=2*sh_audio->audio_in_minsize;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
84 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
85 sh_audio->a_in_buffer_len=0;
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
86
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
90 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
91 ACMSTREAMHEADER ash;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
92 HRESULT hr;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
93 DWORD srcsize=0;
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
94 DWORD len=minlen;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
95 acmStreamSize(sh_audio->srcstream,len , &srcsize, ACM_STREAMSIZEF_DESTINATION);
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
96 if(verbose>=3)printf("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
97
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
98 if(srcsize<sh_audio->wf->nBlockAlign){
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
99 srcsize=sh_audio->wf->nBlockAlign;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
100 acmStreamSize(sh_audio->srcstream, srcsize, &len, ACM_STREAMSIZEF_SOURCE);
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
101 if(len>maxlen) len=maxlen;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
102 }
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
103
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
104 // 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
105 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
106 if(sh_audio->a_in_buffer_len<srcsize){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
107 sh_audio->a_in_buffer_len+=
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
108 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
109 srcsize-sh_audio->a_in_buffer_len);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
110 }
631
1e6e08593762 ACM fixes - now plays april_25.asf too
arpi_esp
parents: 603
diff changeset
111 if(verbose>=3)printf("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
112 memset(&ash, 0, sizeof(ash));
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
113 ash.cbStruct=sizeof(ash);
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
114 ash.fdwStatus=0;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
115 ash.dwUser=0;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
116 ash.pbSrc=sh_audio->a_in_buffer;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
117 ash.cbSrcLength=sh_audio->a_in_buffer_len;
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
118 ash.pbDst=a_buffer;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
119 ash.cbDstLength=len;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
120 hr=acmStreamPrepareHeader(sh_audio->srcstream,&ash,0);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
121 if(hr){
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
122 printf("ACM_Decoder: acmStreamPrepareHeader error %d\n",(int)hr);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
123 return -1;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
124 }
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
125 hr=acmStreamConvert(sh_audio->srcstream,&ash,0);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
126 if(hr){
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 714
diff changeset
127 if(verbose>=2) printf("ACM_Decoder: acmStreamConvert error %d\n",(int)hr);
631
1e6e08593762 ACM fixes - now plays april_25.asf too
arpi_esp
parents: 603
diff changeset
128
1e6e08593762 ACM fixes - now plays april_25.asf too
arpi_esp
parents: 603
diff changeset
129 // return -1;
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
130 }
1407
2e23a033d6f8 acm convert message verbose1->2
arpi
parents: 1309
diff changeset
131 if(verbose>1)
754
32a8e9e43d94 debug printfs moved to -v
arpi_esp
parents: 746
diff changeset
132 printf("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
133 if(ash.cbSrcLengthUsed>=sh_audio->a_in_buffer_len){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
134 sh_audio->a_in_buffer_len=0;
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
135 } else {
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
136 sh_audio->a_in_buffer_len-=ash.cbSrcLengthUsed;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
137 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
138 }
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
139 len=ash.cbDstLengthUsed;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
140 hr=acmStreamUnprepareHeader(sh_audio->srcstream,&ash,0);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
141 if(hr){
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
142 printf("ACM_Decoder: acmStreamUnprepareHeader error %d\n",(int)hr);
92
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
143 }
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
144 return len;
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
145 }
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
146
92776006958f ACM code cleanup, nosound at ACM error
arpi_esp
parents: 1
diff changeset
147
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148
1297
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
149 int init_video_codec(sh_video_t *sh_video,int ex){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 HRESULT ret;
489
2bb59b7c748a BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents: 469
diff changeset
151 int yuv=0;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
152 unsigned int outfmt=sh_video->codec->outfmt[sh_video->outfmtidx];
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 if(verbose) printf("======= Win32 (VFW) VIDEO Codec init =======\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
156 memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER));
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
157 sh_video->o_bih.biSize = sizeof(BITMAPINFOHEADER);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
159 win32_codec_name = sh_video->codec->dll;
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 714
diff changeset
160 // 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
161 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
162 if(!sh_video->hic){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 printf("ICOpen failed! unknown codec / wrong parameters?\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
167 // sh_video->bih.biBitCount=32;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168
432
5251b0c57e39 sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents: 414
diff changeset
169 ret = ICDecompressGetFormat(sh_video->hic, sh_video->bih, &sh_video->o_bih);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 if(ret){
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
171 printf("ICDecompressGetFormat failed: Error %d\n", (int)ret);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 if(verbose) printf("ICDecompressGetFormat OK\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 // printf("ICM_DECOMPRESS_QUERY=0x%X",ICM_DECOMPRESS_QUERY);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
178 // sh_video->o_bih.biWidth=sh_video->bih.biWidth;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
179 // 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
180 // ret=ICDecompressGetFormatSize(sh_video->hic,&sh_video->o_bih);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
181 // sh_video->o_bih.biCompression = 3; //0x32315659;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
182 // 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
183 // 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
184 // 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
185 // sh_video->o_bih.biPlanes=3;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
186 // sh_video->o_bih.biBitCount=16;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 631
diff changeset
188 #if 0
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 631
diff changeset
189 // workaround for pegasus MJPEG:
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 631
diff changeset
190 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
191 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
192 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
193 #endif
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
194
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
195 switch (outfmt) {
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
196
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
197 /* planar format */
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
198 case IMGFMT_YV12:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
199 case IMGFMT_I420:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
200 case IMGFMT_IYUV:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
201 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
202 yuv=1;
467
e53a9edbee98 fixed yuvhack
arpi_esp
parents: 432
diff changeset
203 break;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
205 /* packed format */
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
206 case IMGFMT_YUY2:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
207 case IMGFMT_UYVY:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
208 case IMGFMT_YVYU:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
209 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
210 yuv=1;
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
211 break;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
212
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
213 /* rgb/bgr format */
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
214 case IMGFMT_RGB8:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
215 case IMGFMT_BGR8:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
216 sh_video->o_bih.biBitCount=8;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
217 break;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
219 case IMGFMT_RGB15:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
220 case IMGFMT_RGB16:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
221 case IMGFMT_BGR15:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
222 case IMGFMT_BGR16:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
223 sh_video->o_bih.biBitCount=16;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
224 break;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
225
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
226 case IMGFMT_RGB24:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
227 case IMGFMT_BGR24:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
228 sh_video->o_bih.biBitCount=24;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
229 break;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
230
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
231 case IMGFMT_RGB32:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
232 case IMGFMT_BGR32:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
233 sh_video->o_bih.biBitCount=32;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
234 break;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
236 default:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
237 printf("unsupported image format: 0x%x\n", outfmt);
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
238 return 0;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
239 }
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
240
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
241 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
242
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
243 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
244 sh_video->o_bih.biHeight=-sh_video->bih->biHeight; // flip image!
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 303
diff changeset
245 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246
489
2bb59b7c748a BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents: 469
diff changeset
247 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
248 sh_video->o_bih.biCompression = outfmt;
759
34edf774ef73 HuffYUV YUY2->RGB fixed
arpi_esp
parents: 758
diff changeset
249 else
34edf774ef73 HuffYUV YUY2->RGB fixed
arpi_esp
parents: 758
diff changeset
250 sh_video->o_bih.biCompression = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 if(verbose) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 printf("Starting decompression, format:\n");
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
254 printf(" biSize %ld\n", sh_video->bih->biSize);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
255 printf(" biWidth %ld\n", sh_video->bih->biWidth);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
256 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
257 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
258 printf(" biBitCount %d\n", sh_video->bih->biBitCount);
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
259 printf(" biCompression 0x%lx ('%.4s')\n", sh_video->bih->biCompression, (char *)&sh_video->bih->biCompression);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
260 printf(" biSizeImage %ld\n", sh_video->bih->biSizeImage);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 printf("Dest fmt:\n");
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
262 printf(" biSize %ld\n", sh_video->o_bih.biSize);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
263 printf(" biWidth %ld\n", sh_video->o_bih.biWidth);
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
264 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
265 printf(" biPlanes %d\n", sh_video->o_bih.biPlanes);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
266 printf(" biBitCount %d\n", sh_video->o_bih.biBitCount);
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
267 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
268 printf(" biSizeImage %ld\n", sh_video->o_bih.biSizeImage);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270
1297
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
271 ret = ex ?
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
272 ICDecompressQueryEx(sh_video->hic, sh_video->bih, &sh_video->o_bih) :
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
273 ICDecompressQuery(sh_video->hic, sh_video->bih, &sh_video->o_bih);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 if(ret){
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
275 printf("ICDecompressQuery failed: Error %d\n", (int)ret);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 if(verbose) printf("ICDecompressQuery OK\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279
1297
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
280 ret = ex ?
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
281 ICDecompressBeginEx(sh_video->hic, sh_video->bih, &sh_video->o_bih) :
200c03672178 VfwEx support
arpi
parents: 759
diff changeset
282 ICDecompressBegin(sh_video->hic, sh_video->bih, &sh_video->o_bih);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 if(ret){
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
284 printf("ICDecompressBegin failed: Error %d\n", (int)ret);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287
414
a8b17d1f2551 using shmem_alloc instead of malloc
arpi_esp
parents: 408
diff changeset
288 sh_video->our_out_buffer = shmem_alloc(sh_video->o_bih.biSizeImage);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 92
diff changeset
289 if(!sh_video->our_out_buffer){
603
eda2df9f985d warnings killed
szabii
parents: 587
diff changeset
290 printf("not enough memory for decoded picture buffer (%ld bytes)\n", sh_video->o_bih.biSizeImage);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293
489
2bb59b7c748a BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents: 469
diff changeset
294 if(yuv && sh_video->codec->outflags[sh_video->outfmtidx] & CODECS_FLAG_YUVHACK)
469
434889ca2340 ehh typo...
arpi_esp
parents: 467
diff changeset
295 sh_video->o_bih.biCompression = outfmt;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 // avi_header.our_in_buffer=malloc(avi_header.video.dwSuggestedBufferSize); // FIXME!!!!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 if(verbose) printf("VIDEO CODEC Init OK!!! ;-)\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 }