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
cb63a4b3
Commit
cb63a4b3
authored
16 years ago
by
Michael Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
Simplify parser core.
Originally committed as revision 13613 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
40611372
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libavcodec/avcodec.h
+1
-1
1 addition, 1 deletion
libavcodec/avcodec.h
libavcodec/dvbsub_parser.c
+3
-3
3 additions, 3 deletions
libavcodec/dvbsub_parser.c
libavcodec/parser.c
+14
-30
14 additions, 30 deletions
libavcodec/parser.c
with
18 additions
and
34 deletions
libavcodec/avcodec.h
+
1
−
1
View file @
cb63a4b3
...
@@ -2837,6 +2837,7 @@ typedef struct AVCodecParserContext {
...
@@ -2837,6 +2837,7 @@ typedef struct AVCodecParserContext {
#define AV_PARSER_PTS_NB 4
#define AV_PARSER_PTS_NB 4
int
cur_frame_start_index
;
int
cur_frame_start_index
;
int64_t
cur_frame_offset
[
AV_PARSER_PTS_NB
];
int64_t
cur_frame_offset
[
AV_PARSER_PTS_NB
];
int64_t
cur_frame_end
[
AV_PARSER_PTS_NB
];
int64_t
cur_frame_pts
[
AV_PARSER_PTS_NB
];
int64_t
cur_frame_pts
[
AV_PARSER_PTS_NB
];
int64_t
cur_frame_dts
[
AV_PARSER_PTS_NB
];
int64_t
cur_frame_dts
[
AV_PARSER_PTS_NB
];
...
@@ -2844,7 +2845,6 @@ typedef struct AVCodecParserContext {
...
@@ -2844,7 +2845,6 @@ typedef struct AVCodecParserContext {
#define PARSER_FLAG_COMPLETE_FRAMES 0x0001
#define PARSER_FLAG_COMPLETE_FRAMES 0x0001
int64_t
offset
;
///< byte offset from starting packet start
int64_t
offset
;
///< byte offset from starting packet start
int64_t
last_offset
;
}
AVCodecParserContext
;
}
AVCodecParserContext
;
typedef
struct
AVCodecParser
{
typedef
struct
AVCodecParser
{
...
...
This diff is collapsed.
Click to expand it.
libavcodec/dvbsub_parser.c
+
3
−
3
View file @
cb63a4b3
...
@@ -80,7 +80,7 @@ static int dvbsub_parse(AVCodecParserContext *s,
...
@@ -80,7 +80,7 @@ static int dvbsub_parse(AVCodecParserContext *s,
s
->
fetch_timestamp
=
1
;
s
->
fetch_timestamp
=
1
;
if
(
s
->
last_pts
!=
s
->
pts
&&
s
->
last_
pts
!=
AV_NOPTS_VALUE
)
/* Start of a new packet */
if
(
s
->
last_pts
!=
s
->
pts
&&
s
->
pts
!=
AV_NOPTS_VALUE
)
/* Start of a new packet */
{
{
if
(
pc
->
packet_index
!=
pc
->
packet_start
)
if
(
pc
->
packet_index
!=
pc
->
packet_start
)
{
{
...
@@ -175,8 +175,8 @@ static int dvbsub_parse(AVCodecParserContext *s,
...
@@ -175,8 +175,8 @@ static int dvbsub_parse(AVCodecParserContext *s,
pc
->
packet_start
=
*
poutbuf_size
;
pc
->
packet_start
=
*
poutbuf_size
;
}
}
if
(
s
->
last_
pts
==
AV_NOPTS_VALUE
)
if
(
s
->
pts
==
AV_NOPTS_VALUE
)
s
->
last_
pts
=
s
->
pts
;
s
->
pts
=
s
->
last_
pts
;
return
buf_size
;
return
buf_size
;
}
}
...
...
This diff is collapsed.
Click to expand it.
libavcodec/parser.c
+
14
−
30
View file @
cb63a4b3
...
@@ -118,17 +118,25 @@ int av_parser_parse(AVCodecParserContext *s,
...
@@ -118,17 +118,25 @@ int av_parser_parse(AVCodecParserContext *s,
k
=
(
s
->
cur_frame_start_index
+
1
)
&
(
AV_PARSER_PTS_NB
-
1
);
k
=
(
s
->
cur_frame_start_index
+
1
)
&
(
AV_PARSER_PTS_NB
-
1
);
s
->
cur_frame_start_index
=
k
;
s
->
cur_frame_start_index
=
k
;
s
->
cur_frame_offset
[
k
]
=
s
->
cur_offset
;
s
->
cur_frame_offset
[
k
]
=
s
->
cur_offset
;
s
->
cur_frame_end
[
k
]
=
s
->
cur_offset
+
buf_size
;
s
->
cur_frame_pts
[
k
]
=
pts
;
s
->
cur_frame_pts
[
k
]
=
pts
;
s
->
cur_frame_dts
[
k
]
=
dts
;
s
->
cur_frame_dts
[
k
]
=
dts
;
}
/* fill first PTS/DTS */
if
(
s
->
fetch_timestamp
){
if
(
s
->
fetch_timestamp
){
s
->
fetch_timestamp
=
0
;
s
->
fetch_timestamp
=
0
;
s
->
last_pts
=
pts
;
s
->
last_pts
=
s
->
pts
;
s
->
last_dts
=
dts
;
s
->
last_dts
=
s
->
dts
;
s
->
last_offset
=
0
;
s
->
dts
=
s
->
pts
=
AV_NOPTS_VALUE
;
s
->
cur_frame_pts
[
k
]
=
s
->
offset
=
0
;
s
->
cur_frame_dts
[
k
]
=
AV_NOPTS_VALUE
;
for
(
i
=
0
;
i
<
AV_PARSER_PTS_NB
;
i
++
)
{
if
(
s
->
last_frame_offset
>=
s
->
cur_frame_offset
[
i
]
&&
(
s
->
frame_offset
<
s
->
cur_frame_offset
[
i
]
||
!
s
->
frame_offset
)
&&
s
->
last_frame_offset
<
s
->
cur_frame_end
[
i
]){
s
->
dts
=
s
->
cur_frame_dts
[
i
];
s
->
pts
=
s
->
cur_frame_pts
[
i
];
s
->
offset
=
s
->
last_frame_offset
-
s
->
cur_frame_offset
[
i
];
}
}
}
}
}
...
@@ -139,34 +147,10 @@ int av_parser_parse(AVCodecParserContext *s,
...
@@ -139,34 +147,10 @@ int av_parser_parse(AVCodecParserContext *s,
if
(
*
poutbuf_size
)
{
if
(
*
poutbuf_size
)
{
/* fill the data for the current frame */
/* fill the data for the current frame */
s
->
frame_offset
=
s
->
last_frame_offset
;
s
->
frame_offset
=
s
->
last_frame_offset
;
s
->
pts
=
s
->
last_pts
;
s
->
dts
=
s
->
last_dts
;
s
->
offset
=
s
->
last_offset
;
/* offset of the next frame */
/* offset of the next frame */
s
->
last_frame_offset
=
s
->
cur_offset
+
index
;
s
->
last_frame_offset
=
s
->
cur_offset
+
index
;
/* find the packet in which the new frame starts. It
is tricky because of MPEG video start codes
which can begin in one packet and finish in
another packet. In the worst case, an MPEG
video start code could be in 4 different
packets. */
k
=
s
->
cur_frame_start_index
;
for
(
i
=
0
;
i
<
AV_PARSER_PTS_NB
;
i
++
)
{
if
(
s
->
last_frame_offset
>=
s
->
cur_frame_offset
[
k
])
break
;
k
=
(
k
-
1
)
&
(
AV_PARSER_PTS_NB
-
1
);
}
s
->
last_pts
=
s
->
cur_frame_pts
[
k
];
s
->
last_dts
=
s
->
cur_frame_dts
[
k
];
s
->
last_offset
=
s
->
last_frame_offset
-
s
->
cur_frame_offset
[
k
];
/* some parsers tell us the packet size even before seeing the first byte of the next packet,
so the next pts/dts is in the next chunk */
if
(
index
==
buf_size
){
s
->
fetch_timestamp
=
1
;
s
->
fetch_timestamp
=
1
;
}
}
}
if
(
index
<
0
)
if
(
index
<
0
)
index
=
0
;
index
=
0
;
...
...
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