Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
1b5bd405
Commit
1b5bd405
authored
Nov 30, 2015
by
Rodger Combs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf/mpegtsenc: add automatic bitstream filtering
parent
b287d7ea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
30 deletions
+35
-30
mpegtsenc.c
libavformat/mpegtsenc.c
+35
-30
No files found.
libavformat/mpegtsenc.c
View file @
1b5bd405
...
...
@@ -717,7 +717,7 @@ static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
avio_write
(
ctx
->
pb
,
packet
,
TS_PACKET_SIZE
);
}
static
int
mpegts_
write_header
(
AVFormatContext
*
s
)
static
int
mpegts_
init
(
AVFormatContext
*
s
)
{
MpegTSWrite
*
ts
=
s
->
priv_data
;
MpegTSWriteStream
*
ts_st
;
...
...
@@ -960,26 +960,6 @@ static int mpegts_write_header(AVFormatContext *s)
fail:
av_freep
(
&
pids
);
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
st
=
s
->
streams
[
i
];
ts_st
=
st
->
priv_data
;
if
(
ts_st
)
{
av_freep
(
&
ts_st
->
payload
);
if
(
ts_st
->
amux
)
{
avformat_free_context
(
ts_st
->
amux
);
ts_st
->
amux
=
NULL
;
}
}
av_freep
(
&
st
->
priv_data
);
}
for
(
i
=
0
;
i
<
ts
->
nb_services
;
i
++
)
{
service
=
ts
->
services
[
i
];
av_freep
(
&
service
->
provider_name
);
av_freep
(
&
service
->
name
);
av_freep
(
&
service
);
}
av_freep
(
&
ts
->
services
);
return
ret
;
}
...
...
@@ -1713,21 +1693,28 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
}
static
int
mpegts_write_end
(
AVFormatContext
*
s
)
{
if
(
s
->
pb
)
mpegts_write_flush
(
s
);
return
0
;
}
static
void
mpegts_deinit
(
AVFormatContext
*
s
)
{
MpegTSWrite
*
ts
=
s
->
priv_data
;
MpegTSService
*
service
;
int
i
;
if
(
s
->
pb
)
mpegts_write_flush
(
s
);
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
AVStream
*
st
=
s
->
streams
[
i
];
MpegTSWriteStream
*
ts_st
=
st
->
priv_data
;
av_freep
(
&
ts_st
->
payload
);
if
(
ts_st
->
amux
)
{
avformat_free_context
(
ts_st
->
amux
);
ts_st
->
amux
=
NULL
;
if
(
ts_st
)
{
av_freep
(
&
ts_st
->
payload
);
if
(
ts_st
->
amux
)
{
avformat_free_context
(
ts_st
->
amux
);
ts_st
->
amux
=
NULL
;
}
}
}
...
...
@@ -1738,8 +1725,24 @@ static int mpegts_write_end(AVFormatContext *s)
av_freep
(
&
service
);
}
av_freep
(
&
ts
->
services
);
}
return
0
;
static
int
mpegts_check_bitstream
(
struct
AVFormatContext
*
s
,
const
AVPacket
*
pkt
)
{
int
ret
=
1
;
AVStream
*
st
=
s
->
streams
[
pkt
->
stream_index
];
if
(
st
->
codec
->
codec_id
==
AV_CODEC_ID_H264
)
{
if
(
pkt
->
size
>=
5
&&
AV_RB32
(
pkt
->
data
)
!=
0x0000001
&&
AV_RB24
(
pkt
->
data
)
!=
0x000001
)
ret
=
ff_stream_add_bitstream_filter
(
st
,
"h264_mp4toannexb"
,
NULL
);
}
else
if
(
st
->
codec
->
codec_id
==
AV_CODEC_ID_HEVC
)
{
if
(
pkt
->
size
>=
5
&&
AV_RB32
(
pkt
->
data
)
!=
0x0000001
&&
AV_RB24
(
pkt
->
data
)
!=
0x000001
)
ret
=
ff_stream_add_bitstream_filter
(
st
,
"hevc_mp4toannexb"
,
NULL
);
}
return
ret
;
}
static
const
AVOption
options
[]
=
{
...
...
@@ -1846,9 +1849,11 @@ AVOutputFormat ff_mpegts_muxer = {
.
priv_data_size
=
sizeof
(
MpegTSWrite
),
.
audio_codec
=
AV_CODEC_ID_MP2
,
.
video_codec
=
AV_CODEC_ID_MPEG2VIDEO
,
.
write_header
=
mpegts_write_header
,
.
init
=
mpegts_init
,
.
write_packet
=
mpegts_write_packet
,
.
write_trailer
=
mpegts_write_end
,
.
deinit
=
mpegts_deinit
,
.
check_bitstream
=
mpegts_check_bitstream
,
.
flags
=
AVFMT_ALLOW_FLUSH
|
AVFMT_VARIABLE_FPS
,
.
priv_class
=
&
mpegts_muxer_class
,
};
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