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
f03f78bc
Commit
f03f78bc
authored
Sep 21, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpegvideo_enc: handle encoding errors with b_strategy=2
parent
6f733eca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
mpegvideo_enc.c
libavcodec/mpegvideo_enc.c
+18
-0
No files found.
libavcodec/mpegvideo_enc.c
View file @
f03f78bc
...
...
@@ -1265,6 +1265,7 @@ static int estimate_best_b_count(MpegEncContext *s)
int
i
,
j
,
out_size
,
p_lambda
,
b_lambda
,
lambda2
;
int64_t
best_rd
=
INT64_MAX
;
int
best_b_count
=
-
1
;
int
ret
=
0
;
if
(
!
c
)
return
AVERROR
(
ENOMEM
);
...
...
@@ -1338,6 +1339,10 @@ static int estimate_best_b_count(MpegEncContext *s)
s
->
tmp_frames
[
0
]
->
quality
=
1
*
FF_QP2LAMBDA
;
out_size
=
encode_frame
(
c
,
s
->
tmp_frames
[
0
]);
if
(
out_size
<
0
)
{
ret
=
out_size
;
goto
fail
;
}
//rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT;
...
...
@@ -1349,6 +1354,10 @@ static int estimate_best_b_count(MpegEncContext *s)
s
->
tmp_frames
[
i
+
1
]
->
quality
=
is_p
?
p_lambda
:
b_lambda
;
out_size
=
encode_frame
(
c
,
s
->
tmp_frames
[
i
+
1
]);
if
(
out_size
<
0
)
{
ret
=
out_size
;
goto
fail
;
}
rd
+=
(
out_size
*
lambda2
)
>>
(
FF_LAMBDA_SHIFT
-
3
);
}
...
...
@@ -1356,6 +1365,10 @@ static int estimate_best_b_count(MpegEncContext *s)
/* get the delayed frames */
while
(
out_size
)
{
out_size
=
encode_frame
(
c
,
NULL
);
if
(
out_size
<
0
)
{
ret
=
out_size
;
goto
fail
;
}
rd
+=
(
out_size
*
lambda2
)
>>
(
FF_LAMBDA_SHIFT
-
3
);
}
...
...
@@ -1370,6 +1383,9 @@ static int estimate_best_b_count(MpegEncContext *s)
avcodec_free_context
(
&
c
);
return
best_b_count
;
fail:
avcodec_free_context
(
&
c
);
return
ret
;
}
static
int
select_input_picture
(
MpegEncContext
*
s
)
...
...
@@ -1450,6 +1466,8 @@ static int select_input_picture(MpegEncContext *s)
}
}
else
if
(
s
->
b_frame_strategy
==
2
)
{
b_frames
=
estimate_best_b_count
(
s
);
if
(
b_frames
<
0
)
return
b_frames
;
}
emms_c
();
...
...
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