55 res = AVIFileOpen(&avs->
file, s->
filename, OF_READ|OF_SHARE_DENY_WRITE,
NULL);
63 res = AVIFileInfo(avs->
file, &info,
sizeof(info));
73 for (
id=0;
id<info.dwStreams;
id++)
77 if (AVIFileGetStream(avs->
file, &stream->
handle, 0,
id) == S_OK)
79 if (AVIStreamInfo(stream->
handle, &stream->
info,
sizeof(stream->
info)) == S_OK)
81 if (stream->
info.fccType == streamtypeAUDIO)
84 LONG struct_size =
sizeof(WAVEFORMATEX);
85 if (AVIStreamReadFormat(stream->
handle, 0, &wvfmt, &struct_size) != S_OK)
98 stream->
chunck_samples = wvfmt.nSamplesPerSec * (uint64_t)info.dwScale / (uint64_t)info.dwRate;
104 else if (stream->
info.fccType == streamtypeVIDEO)
107 LONG struct_size =
sizeof(BITMAPINFO);
112 if (AVIStreamReadFormat(stream->
handle, 0, &imgfmt, &struct_size) != S_OK)
125 st->
codec->
bit_rate = (uint64_t)stream->
info.dwSampleSize * (uint64_t)stream->
info.dwRate * 8 / (uint64_t)stream->
info.dwScale;
133 AVIStreamRelease(stream->
handle);
159 stream = &avs->
streams[stream_id];
161 if (stream->
read >= stream->
info.dwLength)
172 pkt->
size = read_size;
181 return (res == S_OK) ? pkt->
size : -1;
195 AVIFileRelease(avs->
file);
205 for (stream_id = 0; stream_id < avs->
nb_streams; stream_id++)