Lines Matching refs:wf
73 WtvFile *wf = opaque;
74 AVIOContext *pb = wf->pb_filesystem;
77 if (wf->error || pb->error)
79 if (wf->position >= wf->length || avio_feof(pb))
82 buf_size = FFMIN(buf_size, wf->length - wf->position);
84 int remaining_in_sector = (1 << wf->sector_bits) - (wf->position & ((1 << wf->sector_bits) - 1));
92 wf->position += n;
94 int i = wf->position >> wf->sector_bits;
95 if (i >= wf->nb_sectors ||
96 (wf->sectors[i] != wf->sectors[i - 1] + (1 << (wf->sector_bits - WTV_SECTOR_BITS)) &&
97 seek_by_sector(pb, wf->sectors[i], 0) < 0)) {
98 wf->error = 1;
111 WtvFile *wf = opaque;
112 AVIOContext *pb = wf->pb_filesystem;
115 return wf->length;
117 offset = wf->position + offset;
119 offset = wf->length;
121 wf->error = offset < 0 || offset >= wf->length ||
122 seek_by_sector(pb, wf->sectors[offset >> wf->sector_bits],
123 offset & ((1 << wf->sector_bits) - 1)) < 0;
124 wf->position = offset;
155 WtvFile *wf;
162 wf = av_mallocz(sizeof(WtvFile));
163 if (!wf)
167 wf->sectors = av_malloc(sizeof(uint32_t));
168 if (!wf->sectors) {
169 av_free(wf);
172 wf->sectors[0] = first_sector;
173 wf->nb_sectors = 1;
175 wf->sectors = av_malloc(WTV_SECTOR_SIZE);
176 if (!wf->sectors) {
177 av_free(wf);
180 wf->nb_sectors = read_ints(s->pb, wf->sectors, WTV_SECTOR_SIZE / 4);
186 wf->sectors = av_malloc_array(nb_sectors1, 1 << WTV_SECTOR_BITS);
187 if (!wf->sectors) {
188 av_free(wf);
191 wf->nb_sectors = 0;
195 wf->nb_sectors += read_ints(s->pb, wf->sectors + i * WTV_SECTOR_SIZE / 4, WTV_SECTOR_SIZE / 4);
199 av_free(wf);
202 wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS;
204 if (!wf->nb_sectors) {
205 av_freep(&wf->sectors);
206 av_freep(&wf);
211 if (size >= 0 && (int64_t)wf->sectors[wf->nb_sectors - 1] << WTV_SECTOR_BITS > size)
216 if (length > ((int64_t)wf->nb_sectors << wf->sector_bits)) {
217 av_log(s, AV_LOG_WARNING, "reported file length (0x%"PRIx64") exceeds number of available sectors (0x%"PRIx64")\n", length, (int64_t)wf->nb_sectors << wf->sector_bits);
218 length = (int64_t)wf->nb_sectors << wf->sector_bits;
220 wf->length = length;
223 wf->position = 0;
224 if (seek_by_sector(s->pb, wf->sectors[0], 0) < 0) {
225 av_freep(&wf->sectors);
226 av_freep(&wf);
230 wf->pb_filesystem = s->pb;
231 buffer = av_malloc(1 << wf->sector_bits);
233 av_freep(&wf->sectors);
234 av_freep(&wf);
238 pb = avio_alloc_context(buffer, 1 << wf->sector_bits, 0, wf,
242 av_freep(&wf->sectors);
243 av_freep(&wf);
309 WtvFile *wf = pb->opaque;
310 av_freep(&wf->sectors);