summaryrefslogtreecommitdiff
path: root/libavformat/asfdec_f.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-24 14:58:07 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-17 04:58:34 +0200
commitfed02825081bd6441f865c9cfcf50e384b2392f5 (patch)
treeb42f4b433b1652e4ad65bc0b5066fe3e80d5662f /libavformat/asfdec_f.c
parentdfbf41775cb58a9218a8b39b0dc6fd8de3f1ab35 (diff)
avformat: Avoid allocation for AVFormatInternal
Do this by allocating AVFormatContext together with the data that is currently in AVFormatInternal; or rather: Put AVFormatContext at the beginning of a new structure called FFFormatContext (which encompasses more than just the internal fields and is a proper context in its own right, hence the name) and remove AVFormatInternal altogether. The biggest simplifications occured in avformat_alloc_context(), where one can now simply call avformat_free_context() in case of errors. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/asfdec_f.c')
-rw-r--r--libavformat/asfdec_f.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index ff6ddfb967..7bdaeda583 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -753,7 +753,7 @@ static int asf_read_header(AVFormatContext *s)
} else {
if (!s->keylen) {
if (!ff_guidcmp(&g, &ff_asf_content_encryption)) {
- AVPacket *pkt = s->internal->parse_pkt;
+ AVPacket *const pkt = ffformatcontext(s)->parse_pkt;
unsigned int len;
av_log(s, AV_LOG_WARNING,
"DRM protected stream detected, decoding will likely fail!\n");
@@ -884,7 +884,7 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext *pb)
if (asf->no_resync_search)
off = 3;
// else if (s->packet_size > 0 && !asf->uses_std_ecc)
-// off = (avio_tell(pb) - s->internal->data_offset) % s->packet_size + 3;
+// off = (avio_tell(pb) - ffformatcontext(s)->data_offset) % s->packet_size + 3;
c = d = e = -1;
while (off-- > 0) {
@@ -1429,6 +1429,7 @@ static int asf_read_close(AVFormatContext *s)
static int64_t asf_read_pts(AVFormatContext *s, int stream_index,
int64_t *ppos, int64_t pos_limit)
{
+ FFFormatContext *const si = ffformatcontext(s);
ASFContext *asf = s->priv_data;
AVPacket pkt1, *pkt = &pkt1;
ASFStream *asf_st;
@@ -1441,9 +1442,9 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index,
start_pos[i] = pos;
if (s->packet_size > 0)
- pos = (pos + s->packet_size - 1 - s->internal->data_offset) /
+ pos = (pos + s->packet_size - 1 - si->data_offset) /
s->packet_size * s->packet_size +
- s->internal->data_offset;
+ si->data_offset;
*ppos = pos;
if (avio_seek(s->pb, pos, SEEK_SET) < 0)
return AV_NOPTS_VALUE;
@@ -1525,7 +1526,7 @@ static int asf_build_simple_index(AVFormatContext *s, int stream_index)
for (i = 0; i < ict; i++) {
int pktnum = avio_rl32(s->pb);
int pktct = avio_rl16(s->pb);
- int64_t pos = s->internal->data_offset + s->packet_size * (int64_t)pktnum;
+ int64_t pos = ffformatcontext(s)->data_offset + s->packet_size * (int64_t)pktnum;
int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
if (avio_feof(s->pb)) {
@@ -1573,7 +1574,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index,
/* explicitly handle the case of seeking to 0 */
if (!pts) {
asf_reset_header(s);
- avio_seek(s->pb, s->internal->data_offset, SEEK_SET);
+ avio_seek(s->pb, ffformatcontext(s)->data_offset, SEEK_SET);
return 0;
}