Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
be448564
Commit
be448564
authored
Nov 19, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/avienc: factor frame skip code out
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
33bc81e4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
avienc.c
libavformat/avienc.c
+32
-16
No files found.
libavformat/avienc.c
View file @
be448564
...
@@ -70,6 +70,8 @@ typedef struct {
...
@@ -70,6 +70,8 @@ typedef struct {
AVIIndex
indexes
;
AVIIndex
indexes
;
}
AVIStream
;
}
AVIStream
;
static
int
avi_write_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
);
static
inline
AVIIentry
*
avi_get_ientry
(
const
AVIIndex
*
idx
,
int
ent_id
)
static
inline
AVIIentry
*
avi_get_ientry
(
const
AVIIndex
*
idx
,
int
ent_id
)
{
{
int
cl
=
ent_id
/
AVI_INDEX_CLUSTER_SIZE
;
int
cl
=
ent_id
/
AVI_INDEX_CLUSTER_SIZE
;
...
@@ -565,6 +567,32 @@ static int avi_write_idx1(AVFormatContext *s)
...
@@ -565,6 +567,32 @@ static int avi_write_idx1(AVFormatContext *s)
return
0
;
return
0
;
}
}
static
int
write_skip_frames
(
AVFormatContext
*
s
,
int
stream_index
,
int64_t
dts
)
{
AVIStream
*
avist
=
s
->
streams
[
stream_index
]
->
priv_data
;
AVCodecContext
*
enc
=
s
->
streams
[
stream_index
]
->
codec
;
av_dlog
(
s
,
"dts:%s packet_count:%d stream_index:%d
\n
"
,
av_ts2str
(
dts
),
avist
->
packet_count
,
stream_index
);
while
(
enc
->
block_align
==
0
&&
dts
!=
AV_NOPTS_VALUE
&&
dts
>
avist
->
packet_count
&&
enc
->
codec_id
!=
AV_CODEC_ID_XSUB
&&
avist
->
packet_count
)
{
AVPacket
empty_packet
;
if
(
dts
-
avist
->
packet_count
>
60000
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Too large number of skipped frames %"
PRId64
" > 60000
\n
"
,
dts
-
avist
->
packet_count
);
return
AVERROR
(
EINVAL
);
}
av_init_packet
(
&
empty_packet
);
empty_packet
.
size
=
0
;
empty_packet
.
data
=
NULL
;
empty_packet
.
stream_index
=
stream_index
;
avi_write_packet
(
s
,
&
empty_packet
);
av_dlog
(
s
,
"dup dts:%s packet_count:%d
\n
"
,
av_ts2str
(
dts
),
avist
->
packet_count
);
}
return
0
;
}
static
int
avi_write_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
static
int
avi_write_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
{
unsigned
char
tag
[
5
];
unsigned
char
tag
[
5
];
...
@@ -575,29 +603,17 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -575,29 +603,17 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
AVIOContext
*
pb
=
s
->
pb
;
AVIOContext
*
pb
=
s
->
pb
;
AVIStream
*
avist
=
s
->
streams
[
stream_index
]
->
priv_data
;
AVIStream
*
avist
=
s
->
streams
[
stream_index
]
->
priv_data
;
AVCodecContext
*
enc
=
s
->
streams
[
stream_index
]
->
codec
;
AVCodecContext
*
enc
=
s
->
streams
[
stream_index
]
->
codec
;
int
ret
;
if
(
enc
->
codec_id
==
AV_CODEC_ID_H264
&&
enc
->
codec_tag
==
MKTAG
(
'H'
,
'2'
,
'6'
,
'4'
)
&&
pkt
->
size
)
{
if
(
enc
->
codec_id
==
AV_CODEC_ID_H264
&&
enc
->
codec_tag
==
MKTAG
(
'H'
,
'2'
,
'6'
,
'4'
)
&&
pkt
->
size
)
{
int
ret
=
ff_check_h264_startcode
(
s
,
s
->
streams
[
stream_index
],
pkt
);
ret
=
ff_check_h264_startcode
(
s
,
s
->
streams
[
stream_index
],
pkt
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
}
}
av_dlog
(
s
,
"dts:%s packet_count:%d stream_index:%d
\n
"
,
av_ts2str
(
pkt
->
dts
),
avist
->
packet_count
,
stream_index
);
while
(
enc
->
block_align
==
0
&&
pkt
->
dts
!=
AV_NOPTS_VALUE
&&
pkt
->
dts
>
avist
->
packet_count
&&
enc
->
codec_id
!=
AV_CODEC_ID_XSUB
&&
avist
->
packet_count
)
{
AVPacket
empty_packet
;
if
(
pkt
->
dts
-
avist
->
packet_count
>
60000
)
{
if
((
ret
=
write_skip_frames
(
s
,
stream_index
,
pkt
->
dts
))
<
0
)
av_log
(
s
,
AV_LOG_ERROR
,
"Too large number of skipped frames %"
PRId64
" > 60000
\n
"
,
pkt
->
dts
-
avist
->
packet_count
);
return
ret
;
return
AVERROR
(
EINVAL
);
}
av_init_packet
(
&
empty_packet
);
empty_packet
.
size
=
0
;
empty_packet
.
data
=
NULL
;
empty_packet
.
stream_index
=
stream_index
;
avi_write_packet
(
s
,
&
empty_packet
);
av_dlog
(
s
,
"dup dts:%s packet_count:%d
\n
"
,
av_ts2str
(
pkt
->
dts
),
avist
->
packet_count
);
}
avist
->
packet_count
++
;
avist
->
packet_count
++
;
// Make sure to put an OpenDML chunk when the file size exceeds the limits
// Make sure to put an OpenDML chunk when the file size exceeds the limits
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment