|
|
@ -204,8 +204,8 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int |
|
|
|
wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS; |
|
|
|
wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS; |
|
|
|
|
|
|
|
|
|
|
|
if (!wf->nb_sectors) { |
|
|
|
if (!wf->nb_sectors) { |
|
|
|
av_free(wf->sectors); |
|
|
|
av_freep(&wf->sectors); |
|
|
|
av_free(wf); |
|
|
|
av_freep(&wf); |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -224,25 +224,25 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int |
|
|
|
/* seek to initial sector */ |
|
|
|
/* seek to initial sector */ |
|
|
|
wf->position = 0; |
|
|
|
wf->position = 0; |
|
|
|
if (seek_by_sector(s->pb, wf->sectors[0], 0) < 0) { |
|
|
|
if (seek_by_sector(s->pb, wf->sectors[0], 0) < 0) { |
|
|
|
av_free(wf->sectors); |
|
|
|
av_freep(&wf->sectors); |
|
|
|
av_free(wf); |
|
|
|
av_freep(&wf); |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wf->pb_filesystem = s->pb; |
|
|
|
wf->pb_filesystem = s->pb; |
|
|
|
buffer = av_malloc(1 << wf->sector_bits); |
|
|
|
buffer = av_malloc(1 << wf->sector_bits); |
|
|
|
if (!buffer) { |
|
|
|
if (!buffer) { |
|
|
|
av_free(wf->sectors); |
|
|
|
av_freep(&wf->sectors); |
|
|
|
av_free(wf); |
|
|
|
av_freep(&wf); |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pb = avio_alloc_context(buffer, 1 << wf->sector_bits, 0, wf, |
|
|
|
pb = avio_alloc_context(buffer, 1 << wf->sector_bits, 0, wf, |
|
|
|
wtvfile_read_packet, NULL, wtvfile_seek); |
|
|
|
wtvfile_read_packet, NULL, wtvfile_seek); |
|
|
|
if (!pb) { |
|
|
|
if (!pb) { |
|
|
|
av_free(buffer); |
|
|
|
av_freep(&buffer); |
|
|
|
av_free(wf->sectors); |
|
|
|
av_freep(&wf->sectors); |
|
|
|
av_free(wf); |
|
|
|
av_freep(&wf); |
|
|
|
} |
|
|
|
} |
|
|
|
return pb; |
|
|
|
return pb; |
|
|
|
} |
|
|
|
} |
|
|
@ -304,7 +304,7 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int b |
|
|
|
static void wtvfile_close(AVIOContext *pb) |
|
|
|
static void wtvfile_close(AVIOContext *pb) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WtvFile *wf = pb->opaque; |
|
|
|
WtvFile *wf = pb->opaque; |
|
|
|
av_free(wf->sectors); |
|
|
|
av_freep(&wf->sectors); |
|
|
|
av_freep(&pb->opaque); |
|
|
|
av_freep(&pb->opaque); |
|
|
|
av_freep(&pb->buffer); |
|
|
|
av_freep(&pb->buffer); |
|
|
|
av_free(pb); |
|
|
|
av_free(pb); |
|
|
|