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
a7fcd412
Commit
a7fcd412
authored
Jun 24, 2014
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output example: store the scaling context in the stream context
parent
6a927d7a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
output.c
doc/examples/output.c
+11
-9
No files found.
doc/examples/output.c
View file @
a7fcd412
...
...
@@ -55,6 +55,8 @@ typedef struct OutputStream {
AVFrame
*
tmp_frame
;
float
t
,
tincr
,
tincr2
;
struct
SwsContext
*
sws_ctx
;
}
OutputStream
;
/**************************************************************/
...
...
@@ -327,7 +329,6 @@ static void write_video_frame(AVFormatContext *oc, OutputStream *ost)
{
int
ret
;
AVCodecContext
*
c
;
static
struct
SwsContext
*
img_convert_ctx
;
c
=
ost
->
st
->
codec
;
...
...
@@ -339,20 +340,20 @@ static void write_video_frame(AVFormatContext *oc, OutputStream *ost)
if
(
c
->
pix_fmt
!=
AV_PIX_FMT_YUV420P
)
{
/* as we only generate a YUV420P picture, we must convert it
* to the codec pixel format if needed */
if
(
img_convert_ctx
==
NULL
)
{
img_convert
_ctx
=
sws_getContext
(
c
->
width
,
c
->
height
,
AV_PIX_FMT_YUV420P
,
c
->
width
,
c
->
height
,
c
->
pix_fmt
,
SCALE_FLAGS
,
NULL
,
NULL
,
NULL
);
if
(
img_convert_ctx
==
NULL
)
{
if
(
!
ost
->
sws_ctx
)
{
ost
->
sws
_ctx
=
sws_getContext
(
c
->
width
,
c
->
height
,
AV_PIX_FMT_YUV420P
,
c
->
width
,
c
->
height
,
c
->
pix_fmt
,
SCALE_FLAGS
,
NULL
,
NULL
,
NULL
);
if
(
!
ost
->
sws_ctx
)
{
fprintf
(
stderr
,
"Cannot initialize the conversion context
\n
"
);
exit
(
1
);
}
}
fill_yuv_image
(
ost
->
tmp_frame
,
frame_count
,
c
->
width
,
c
->
height
);
sws_scale
(
img_convert
_ctx
,
ost
->
tmp_frame
->
data
,
ost
->
tmp_frame
->
linesize
,
sws_scale
(
ost
->
sws
_ctx
,
ost
->
tmp_frame
->
data
,
ost
->
tmp_frame
->
linesize
,
0
,
c
->
height
,
ost
->
frame
->
data
,
ost
->
frame
->
linesize
);
}
else
{
fill_yuv_image
(
ost
->
frame
,
frame_count
,
c
->
width
,
c
->
height
);
...
...
@@ -401,6 +402,7 @@ static void close_stream(AVFormatContext *oc, OutputStream *ost)
avcodec_close
(
ost
->
st
->
codec
);
av_frame_free
(
&
ost
->
frame
);
av_frame_free
(
&
ost
->
tmp_frame
);
sws_freeContext
(
ost
->
sws_ctx
);
}
/**************************************************************/
...
...
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