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
04e36fc4
Commit
04e36fc4
authored
Dec 26, 2019
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/img2enc: factorize piped write_packet
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
b693b06b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
img2enc.c
libavformat/img2enc.c
+18
-12
No files found.
libavformat/img2enc.c
View file @
04e36fc4
...
...
@@ -35,7 +35,6 @@
typedef
struct
VideoMuxData
{
const
AVClass
*
class
;
/**< Class for private options. */
int
img_number
;
int
is_pipe
;
int
split_planes
;
/**< use independent file for each Y, U, V plane */
char
path
[
1024
];
char
tmp
[
4
][
1024
];
...
...
@@ -55,12 +54,6 @@ static int write_header(AVFormatContext *s)
av_strlcpy
(
img
->
path
,
s
->
url
,
sizeof
(
img
->
path
));
/* find format */
if
(
s
->
oformat
->
flags
&
AVFMT_NOFILE
)
img
->
is_pipe
=
0
;
else
img
->
is_pipe
=
1
;
if
(
st
->
codecpar
->
codec_id
==
AV_CODEC_ID_GIF
)
{
img
->
muxer
=
"gif"
;
}
else
if
(
st
->
codecpar
->
codec_id
==
AV_CODEC_ID_FITS
)
{
...
...
@@ -113,6 +106,21 @@ static int write_muxed_file(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
return
0
;
}
static
int
write_packet_pipe
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
VideoMuxData
*
img
=
s
->
priv_data
;
if
(
img
->
muxer
)
{
int
ret
=
write_muxed_file
(
s
,
s
->
pb
,
pkt
);
if
(
ret
<
0
)
return
ret
;
}
else
{
avio_write
(
s
->
pb
,
pkt
->
data
,
pkt
->
size
);
avio_flush
(
s
->
pb
);
}
img
->
img_number
++
;
return
0
;
}
static
int
write_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
VideoMuxData
*
img
=
s
->
priv_data
;
...
...
@@ -123,7 +131,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
int
ret
,
i
;
int
nb_renames
=
0
;
if
(
!
img
->
is_pipe
)
{
{
if
(
img
->
update
)
{
av_strlcpy
(
filename
,
img
->
path
,
sizeof
(
filename
));
}
else
if
(
img
->
use_strftime
)
{
...
...
@@ -164,8 +172,6 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
}
if
(
img
->
use_rename
)
nb_renames
=
i
+
1
;
}
else
{
pb
[
0
]
=
s
->
pb
;
}
if
(
img
->
split_planes
)
{
...
...
@@ -192,7 +198,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
avio_write
(
pb
[
0
],
pkt
->
data
,
pkt
->
size
);
}
avio_flush
(
pb
[
0
]);
if
(
!
img
->
is_pipe
)
{
{
ff_format_io_close
(
s
,
&
pb
[
0
]);
for
(
i
=
0
;
i
<
nb_renames
;
i
++
)
{
int
ret
=
ff_rename
(
img
->
tmp
[
i
],
img
->
target
[
i
],
s
);
...
...
@@ -257,7 +263,7 @@ AVOutputFormat ff_image2pipe_muxer = {
.
priv_data_size
=
sizeof
(
VideoMuxData
),
.
video_codec
=
AV_CODEC_ID_MJPEG
,
.
write_header
=
write_header
,
.
write_packet
=
write_packet
,
.
write_packet
=
write_packet
_pipe
,
.
query_codec
=
query_codec
,
.
flags
=
AVFMT_NOTIMESTAMPS
|
AVFMT_NODIMENSIONS
};
...
...
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