Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
d3f610c1
Commit
d3f610c1
authored
13 years ago
by
Alex Converse
Browse files
Options
Downloads
Patches
Plain Diff
avidec: infer absolute vs relative index from first packet
parent
23ce6e72
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavformat/avidec.c
+23
-7
23 additions, 7 deletions
libavformat/avidec.c
with
23 additions
and
7 deletions
libavformat/avidec.c
+
23
−
7
View file @
d3f610c1
...
@@ -836,7 +836,7 @@ static int get_stream_idx(int *d){
...
@@ -836,7 +836,7 @@ static int get_stream_idx(int *d){
}
}
}
}
static
int
avi_sync
(
AVFormatContext
*
s
)
static
int
avi_sync
(
AVFormatContext
*
s
,
int
exit_early
)
{
{
AVIContext
*
avi
=
s
->
priv_data
;
AVIContext
*
avi
=
s
->
priv_data
;
AVIOContext
*
pb
=
s
->
pb
;
AVIOContext
*
pb
=
s
->
pb
;
...
@@ -916,7 +916,9 @@ start_sync:
...
@@ -916,7 +916,9 @@ start_sync:
if
(
(
st
->
discard
>=
AVDISCARD_DEFAULT
&&
size
==
0
)
if
(
(
st
->
discard
>=
AVDISCARD_DEFAULT
&&
size
==
0
)
/*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/
//FIXME needs a little reordering
/*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/
//FIXME needs a little reordering
||
st
->
discard
>=
AVDISCARD_ALL
){
||
st
->
discard
>=
AVDISCARD_ALL
){
ast
->
frame_offset
+=
get_duration
(
ast
,
size
);
if
(
!
exit_early
)
{
ast
->
frame_offset
+=
get_duration
(
ast
,
size
);
}
avio_skip
(
pb
,
size
);
avio_skip
(
pb
,
size
);
goto
start_sync
;
goto
start_sync
;
}
}
...
@@ -936,6 +938,8 @@ start_sync:
...
@@ -936,6 +938,8 @@ start_sync:
(d[2] == 'd' && d[3] == 'c') ||
(d[2] == 'd' && d[3] == 'c') ||
(d[2] == 'w' && d[3] == 'b')*/
)
{
(d[2] == 'w' && d[3] == 'b')*/
)
{
if
(
exit_early
)
return
0
;
//av_log(s, AV_LOG_DEBUG, "OK\n");
//av_log(s, AV_LOG_DEBUG, "OK\n");
if
(
d
[
2
]
*
256
+
d
[
3
]
==
ast
->
prefix
)
if
(
d
[
2
]
*
256
+
d
[
3
]
==
ast
->
prefix
)
ast
->
prefix_count
++
;
ast
->
prefix_count
++
;
...
@@ -1117,7 +1121,7 @@ resync:
...
@@ -1117,7 +1121,7 @@ resync:
return
size
;
return
size
;
}
}
if
((
err
=
avi_sync
(
s
))
<
0
)
if
((
err
=
avi_sync
(
s
,
0
))
<
0
)
return
err
;
return
err
;
goto
resync
;
goto
resync
;
}
}
...
@@ -1131,13 +1135,22 @@ static int avi_read_idx1(AVFormatContext *s, int size)
...
@@ -1131,13 +1135,22 @@ static int avi_read_idx1(AVFormatContext *s, int size)
int
nb_index_entries
,
i
;
int
nb_index_entries
,
i
;
AVStream
*
st
;
AVStream
*
st
;
AVIStream
*
ast
;
AVIStream
*
ast
;
unsigned
int
index
,
tag
,
flags
,
pos
,
len
;
unsigned
int
index
,
tag
,
flags
,
pos
,
len
,
first_packet
=
1
;
unsigned
last_pos
=
-
1
;
unsigned
last_pos
=
-
1
;
int64_t
idx1_pos
,
first_packet_pos
=
0
,
data_offset
=
0
;
nb_index_entries
=
size
/
16
;
nb_index_entries
=
size
/
16
;
if
(
nb_index_entries
<=
0
)
if
(
nb_index_entries
<=
0
)
return
-
1
;
return
-
1
;
idx1_pos
=
avio_tell
(
pb
);
avio_seek
(
pb
,
avi
->
movi_list
+
4
,
SEEK_SET
);
if
(
avi_sync
(
s
,
1
)
==
0
)
{
first_packet_pos
=
avio_tell
(
pb
)
-
8
;
}
avi
->
stream_index
=
-
1
;
avio_seek
(
pb
,
idx1_pos
,
SEEK_SET
);
/* Read the entries and sort them in each stream component. */
/* Read the entries and sort them in each stream component. */
for
(
i
=
0
;
i
<
nb_index_entries
;
i
++
)
{
for
(
i
=
0
;
i
<
nb_index_entries
;
i
++
)
{
tag
=
avio_rl32
(
pb
);
tag
=
avio_rl32
(
pb
);
...
@@ -1146,9 +1159,6 @@ static int avi_read_idx1(AVFormatContext *s, int size)
...
@@ -1146,9 +1159,6 @@ static int avi_read_idx1(AVFormatContext *s, int size)
len
=
avio_rl32
(
pb
);
len
=
avio_rl32
(
pb
);
av_dlog
(
s
,
"%d: tag=0x%x flags=0x%x pos=0x%x len=%d/"
,
av_dlog
(
s
,
"%d: tag=0x%x flags=0x%x pos=0x%x len=%d/"
,
i
,
tag
,
flags
,
pos
,
len
);
i
,
tag
,
flags
,
pos
,
len
);
if
(
i
==
0
&&
pos
>
avi
->
movi_list
)
avi
->
movi_list
=
0
;
//FIXME better check
pos
+=
avi
->
movi_list
;
index
=
((
tag
&
0xff
)
-
'0'
)
*
10
;
index
=
((
tag
&
0xff
)
-
'0'
)
*
10
;
index
+=
((
tag
>>
8
)
&
0xff
)
-
'0'
;
index
+=
((
tag
>>
8
)
&
0xff
)
-
'0'
;
...
@@ -1157,6 +1167,12 @@ static int avi_read_idx1(AVFormatContext *s, int size)
...
@@ -1157,6 +1167,12 @@ static int avi_read_idx1(AVFormatContext *s, int size)
st
=
s
->
streams
[
index
];
st
=
s
->
streams
[
index
];
ast
=
st
->
priv_data
;
ast
=
st
->
priv_data
;
if
(
first_packet
&&
first_packet_pos
&&
len
)
{
data_offset
=
first_packet_pos
-
pos
;
first_packet
=
0
;
}
pos
+=
data_offset
;
av_dlog
(
s
,
"%d cum_len=%"
PRId64
"
\n
"
,
len
,
ast
->
cum_len
);
av_dlog
(
s
,
"%d cum_len=%"
PRId64
"
\n
"
,
len
,
ast
->
cum_len
);
if
(
pb
->
eof_reached
)
if
(
pb
->
eof_reached
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment