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
2c8b796f
Commit
2c8b796f
authored
Jan 29, 2004
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
b frames + cbr fix
Originally committed as revision 2730 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
8fd19ab2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
40 deletions
+43
-40
mpegvideo.c
libavcodec/mpegvideo.c
+43
-40
No files found.
libavcodec/mpegvideo.c
View file @
2c8b796f
...
@@ -1939,53 +1939,56 @@ int MPV_encode_picture(AVCodecContext *avctx,
...
@@ -1939,53 +1939,56 @@ int MPV_encode_picture(AVCodecContext *avctx,
for
(
i
=
0
;
i
<
4
;
i
++
){
for
(
i
=
0
;
i
<
4
;
i
++
){
avctx
->
error
[
i
]
+=
s
->
current_picture_ptr
->
error
[
i
];
avctx
->
error
[
i
]
+=
s
->
current_picture_ptr
->
error
[
i
];
}
}
}
flush_put_bits
(
&
s
->
pb
);
s
->
frame_bits
=
(
pbBufPtr
(
&
s
->
pb
)
-
s
->
pb
.
buf
)
*
8
;
stuffing_count
=
ff_vbv_update
(
s
,
s
->
frame_bits
);
if
(
stuffing_count
){
switch
(
s
->
codec_id
){
case
CODEC_ID_MPEG1VIDEO
:
case
CODEC_ID_MPEG2VIDEO
:
while
(
stuffing_count
--
){
put_bits
(
&
s
->
pb
,
8
,
0
);
}
break
;
case
CODEC_ID_MPEG4
:
put_bits
(
&
s
->
pb
,
16
,
0
);
put_bits
(
&
s
->
pb
,
16
,
0x1C3
);
stuffing_count
-=
4
;
while
(
stuffing_count
--
){
put_bits
(
&
s
->
pb
,
8
,
0xFF
);
}
break
;
default
:
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"vbv buffer overflow
\n
"
);
}
flush_put_bits
(
&
s
->
pb
);
flush_put_bits
(
&
s
->
pb
);
s
->
frame_bits
=
(
pbBufPtr
(
&
s
->
pb
)
-
s
->
pb
.
buf
)
*
8
;
s
->
frame_bits
=
(
pbBufPtr
(
&
s
->
pb
)
-
s
->
pb
.
buf
)
*
8
;
}
/* update mpeg1/2 vbv_delay for CBR */
stuffing_count
=
ff_vbv_update
(
s
,
s
->
frame_bits
);
if
(
s
->
avctx
->
rc_max_rate
&&
s
->
avctx
->
rc_min_rate
==
s
->
avctx
->
rc_max_rate
){
if
(
stuffing_count
){
int
vbv_delay
;
switch
(
s
->
codec_id
){
case
CODEC_ID_MPEG1VIDEO
:
case
CODEC_ID_MPEG2VIDEO
:
while
(
stuffing_count
--
){
put_bits
(
&
s
->
pb
,
8
,
0
);
}
break
;
case
CODEC_ID_MPEG4
:
put_bits
(
&
s
->
pb
,
16
,
0
);
put_bits
(
&
s
->
pb
,
16
,
0x1C3
);
stuffing_count
-=
4
;
while
(
stuffing_count
--
){
put_bits
(
&
s
->
pb
,
8
,
0xFF
);
}
break
;
default
:
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"vbv buffer overflow
\n
"
);
}
flush_put_bits
(
&
s
->
pb
);
s
->
frame_bits
=
(
pbBufPtr
(
&
s
->
pb
)
-
s
->
pb
.
buf
)
*
8
;
}
assert
(
s
->
repeat_first_field
==
0
);
/* update mpeg1/2 vbv_delay for CBR */
if
(
s
->
avctx
->
rc_max_rate
&&
s
->
avctx
->
rc_min_rate
==
s
->
avctx
->
rc_max_rate
){
vbv_delay
=
lrintf
(
90000
*
s
->
rc_context
.
buffer_index
/
s
->
avctx
->
rc_max_rate
);
int
vbv_delay
;
assert
(
vbv_delay
<
0xFFFF
);
s
->
vbv_delay_ptr
[
0
]
&=
0xF8
;
assert
(
s
->
repeat_first_field
==
0
);
s
->
vbv_delay_ptr
[
0
]
|=
vbv_delay
>>
13
;
s
->
vbv_delay_ptr
[
1
]
=
vbv_delay
>>
5
;
vbv_delay
=
lrintf
(
90000
*
s
->
rc_context
.
buffer_index
/
s
->
avctx
->
rc_max_rate
);
s
->
vbv_delay_ptr
[
2
]
&=
0x07
;
assert
(
vbv_delay
<
0xFFFF
);
s
->
vbv_delay_ptr
[
2
]
|=
vbv_delay
<<
3
;
s
->
vbv_delay_ptr
[
0
]
&=
0xF8
;
s
->
vbv_delay_ptr
[
0
]
|=
vbv_delay
>>
13
;
s
->
vbv_delay_ptr
[
1
]
=
vbv_delay
>>
5
;
s
->
vbv_delay_ptr
[
2
]
&=
0x07
;
s
->
vbv_delay_ptr
[
2
]
|=
vbv_delay
<<
3
;
}
s
->
total_bits
+=
s
->
frame_bits
;
avctx
->
frame_bits
=
s
->
frame_bits
;
}
else
{
assert
((
pbBufPtr
(
&
s
->
pb
)
==
s
->
pb
.
buf
));
s
->
frame_bits
=
0
;
}
}
assert
((
s
->
frame_bits
&
7
)
==
0
);
s
->
total_bits
+=
s
->
frame_bits
;
avctx
->
frame_bits
=
s
->
frame_bits
;
return
s
->
frame_bits
/
8
;
return
s
->
frame_bits
/
8
;
}
}
...
...
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