Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
00f3bb2e
Commit
00f3bb2e
authored
May 25, 2015
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/mpegvideo: Factor ff_mpv_reallocate_putbitbuffer() out
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
cf401cd1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
23 deletions
+33
-23
mpegvideo.h
libavcodec/mpegvideo.h
+1
-0
mpegvideo_enc.c
libavcodec/mpegvideo_enc.c
+32
-23
No files found.
libavcodec/mpegvideo.h
View file @
00f3bb2e
...
...
@@ -766,6 +766,7 @@ void ff_mpv_encode_init_x86(MpegEncContext *s);
int
ff_mpv_encode_end
(
AVCodecContext
*
avctx
);
int
ff_mpv_encode_picture
(
AVCodecContext
*
avctx
,
AVPacket
*
pkt
,
const
AVFrame
*
frame
,
int
*
got_packet
);
int
ff_mpv_reallocate_putbitbuffer
(
MpegEncContext
*
s
,
size_t
threshold
,
size_t
size_increase
);
void
ff_clean_intra_table_entries
(
MpegEncContext
*
s
);
void
ff_mpeg_draw_horiz_band
(
MpegEncContext
*
s
,
int
y
,
int
h
);
...
...
libavcodec/mpegvideo_enc.c
View file @
00f3bb2e
...
...
@@ -2719,6 +2719,35 @@ static void update_mb_info(MpegEncContext *s, int startcode)
write_mb_info
(
s
);
}
int
ff_mpv_reallocate_putbitbuffer
(
MpegEncContext
*
s
,
size_t
threshold
,
size_t
size_increase
)
{
if
(
s
->
pb
.
buf_end
-
s
->
pb
.
buf
-
(
put_bits_count
(
&
s
->
pb
)
>>
3
)
<
threshold
&&
s
->
slice_context_count
==
1
&&
s
->
pb
.
buf
==
s
->
avctx
->
internal
->
byte_buffer
)
{
int
lastgob_pos
=
s
->
ptr_lastgob
-
s
->
pb
.
buf
;
int
vbv_pos
=
s
->
vbv_delay_ptr
-
s
->
pb
.
buf
;
uint8_t
*
new_buffer
=
NULL
;
int
new_buffer_size
=
0
;
av_fast_padded_malloc
(
&
new_buffer
,
&
new_buffer_size
,
s
->
avctx
->
internal
->
byte_buffer_size
+
size_increase
);
if
(
!
new_buffer
)
return
AVERROR
(
ENOMEM
);
memcpy
(
new_buffer
,
s
->
avctx
->
internal
->
byte_buffer
,
s
->
avctx
->
internal
->
byte_buffer_size
);
av_free
(
s
->
avctx
->
internal
->
byte_buffer
);
s
->
avctx
->
internal
->
byte_buffer
=
new_buffer
;
s
->
avctx
->
internal
->
byte_buffer_size
=
new_buffer_size
;
rebase_put_bits
(
&
s
->
pb
,
new_buffer
,
new_buffer_size
);
s
->
ptr_lastgob
=
s
->
pb
.
buf
+
lastgob_pos
;
s
->
vbv_delay_ptr
=
s
->
pb
.
buf
+
vbv_pos
;
}
if
(
s
->
pb
.
buf_end
-
s
->
pb
.
buf
-
(
put_bits_count
(
&
s
->
pb
)
>>
3
)
<
threshold
)
return
AVERROR
(
EINVAL
);
return
0
;
}
static
int
encode_thread
(
AVCodecContext
*
c
,
void
*
arg
){
MpegEncContext
*
s
=
*
(
void
**
)
arg
;
int
mb_x
,
mb_y
,
pdif
=
0
;
...
...
@@ -2795,30 +2824,10 @@ static int encode_thread(AVCodecContext *c, void *arg){
// int d;
int
dmin
=
INT_MAX
;
int
dir
;
int
size_increase
=
s
->
avctx
->
internal
->
byte_buffer_size
/
4
+
s
->
mb_width
*
MAX_MB_BYTES
;
if
(
s
->
pb
.
buf_end
-
s
->
pb
.
buf
-
(
put_bits_count
(
&
s
->
pb
)
>>
3
)
<
MAX_MB_BYTES
&&
s
->
slice_context_count
==
1
&&
s
->
pb
.
buf
==
s
->
avctx
->
internal
->
byte_buffer
)
{
int
new_size
=
s
->
avctx
->
internal
->
byte_buffer_size
+
s
->
avctx
->
internal
->
byte_buffer_size
/
4
+
s
->
mb_width
*
MAX_MB_BYTES
;
int
lastgob_pos
=
s
->
ptr_lastgob
-
s
->
pb
.
buf
;
int
vbv_pos
=
s
->
vbv_delay_ptr
-
s
->
pb
.
buf
;
uint8_t
*
new_buffer
=
NULL
;
int
new_buffer_size
=
0
;
av_fast_padded_malloc
(
&
new_buffer
,
&
new_buffer_size
,
new_size
);
if
(
new_buffer
)
{
memcpy
(
new_buffer
,
s
->
avctx
->
internal
->
byte_buffer
,
s
->
avctx
->
internal
->
byte_buffer_size
);
av_free
(
s
->
avctx
->
internal
->
byte_buffer
);
s
->
avctx
->
internal
->
byte_buffer
=
new_buffer
;
s
->
avctx
->
internal
->
byte_buffer_size
=
new_buffer_size
;
rebase_put_bits
(
&
s
->
pb
,
new_buffer
,
new_buffer_size
);
s
->
ptr_lastgob
=
s
->
pb
.
buf
+
lastgob_pos
;
s
->
vbv_delay_ptr
=
s
->
pb
.
buf
+
vbv_pos
;
}
}
ff_mpv_reallocate_putbitbuffer
(
s
,
MAX_MB_BYTES
,
size_increase
);
if
(
s
->
pb
.
buf_end
-
s
->
pb
.
buf
-
(
put_bits_count
(
&
s
->
pb
)
>>
3
)
<
MAX_MB_BYTES
){
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"encoded frame too large
\n
"
);
return
-
1
;
...
...
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