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
e2143067
Commit
e2143067
authored
Oct 04, 2012
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpeg2enc: support and use frame_rate_ext when needed
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
489d8a79
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
11 deletions
+25
-11
mpeg12enc.c
libavcodec/mpeg12enc.c
+24
-11
mpegvideo.h
libavcodec/mpegvideo.h
+1
-0
No files found.
libavcodec/mpeg12enc.c
View file @
e2143067
...
...
@@ -108,21 +108,34 @@ static void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len){
static
int
find_frame_rate_index
(
MpegEncContext
*
s
){
int
i
;
int64_t
dmin
=
INT64_MAX
;
int64_t
d
;
AVRational
bestq
=
(
AVRational
){
0
,
0
};
AVRational
ext
;
AVRational
target
=
av_inv_q
(
s
->
avctx
->
time_base
);
for
(
i
=
1
;
i
<
14
;
i
++
)
{
int64_t
n0
=
1001LL
/
avpriv_frame_rate_tab
[
i
].
den
*
avpriv_frame_rate_tab
[
i
].
num
*
s
->
avctx
->
time_base
.
num
;
int64_t
n1
=
1001LL
*
s
->
avctx
->
time_base
.
den
;
if
(
s
->
avctx
->
strict_std_compliance
>
FF_COMPLIANCE_UNOFFICIAL
&&
i
>=
9
)
break
;
d
=
FFABS
(
n0
-
n1
);
if
(
d
<
dmin
){
dmin
=
d
;
s
->
frame_rate_index
=
i
;
for
(
ext
.
num
=
1
;
ext
.
num
<=
4
;
ext
.
num
++
)
{
for
(
ext
.
den
=
1
;
ext
.
den
<=
32
;
ext
.
den
++
)
{
AVRational
q
=
av_mul_q
(
ext
,
avpriv_frame_rate_tab
[
i
]);
if
(
s
->
codec_id
!=
AV_CODEC_ID_MPEG2VIDEO
&&
(
ext
.
den
!=
1
||
ext
.
num
!=
1
))
continue
;
if
(
av_gcd
(
ext
.
den
,
ext
.
num
)
!=
1
)
continue
;
if
(
bestq
.
num
==
0
||
av_nearer_q
(
target
,
bestq
,
q
)
<
0
||
ext
.
num
==
1
&&
ext
.
den
==
1
&&
av_nearer_q
(
target
,
bestq
,
q
)
==
0
){
bestq
=
q
;
s
->
frame_rate_index
=
i
;
s
->
mpeg2_frame_rate_ext
.
num
=
ext
.
num
;
s
->
mpeg2_frame_rate_ext
.
den
=
ext
.
den
;
}
}
}
}
if
(
dmin
)
if
(
av_cmp_q
(
target
,
bestq
)
)
return
-
1
;
else
return
0
;
...
...
@@ -286,8 +299,8 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits
(
&
s
->
pb
,
1
,
1
);
//marker
put_bits
(
&
s
->
pb
,
8
,
vbv_buffer_size
>>
10
);
//vbv buffer ext
put_bits
(
&
s
->
pb
,
1
,
s
->
low_delay
);
put_bits
(
&
s
->
pb
,
2
,
0
);
// frame_rate_ext_n
put_bits
(
&
s
->
pb
,
5
,
0
);
// frame_rate_ext_d
put_bits
(
&
s
->
pb
,
2
,
s
->
mpeg2_frame_rate_ext
.
num
-
1
);
// frame_rate_ext_n
put_bits
(
&
s
->
pb
,
5
,
s
->
mpeg2_frame_rate_ext
.
den
-
1
);
// frame_rate_ext_d
}
put_header
(
s
,
GOP_START_CODE
);
...
...
libavcodec/mpegvideo.h
View file @
e2143067
...
...
@@ -347,6 +347,7 @@ typedef struct MpegEncContext {
int
last_non_b_pict_type
;
///< used for mpeg4 gmc b-frames & ratecontrol
int
dropable
;
int
frame_rate_index
;
AVRational
mpeg2_frame_rate_ext
;
int
last_lambda_for
[
5
];
///< last lambda for a specific pict type
int
skipdct
;
///< skip dct and code zero residual
...
...
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