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
f0bbfc4a
Commit
f0bbfc4a
authored
Oct 15, 2003
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
default_get_buffer() fixes
Originally committed as revision 2391 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
66535069
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
12 deletions
+52
-12
utils.c
libavcodec/utils.c
+52
-12
No files found.
libavcodec/utils.c
View file @
f0bbfc4a
...
...
@@ -127,10 +127,48 @@ typedef struct InternalBuffer{
#define INTERNAL_BUFFER_SIZE 32
#define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
void
avcodec_align_dimensions
(
AVCodecContext
*
s
,
int
*
width
,
int
*
height
){
int
w_align
=
1
;
int
h_align
=
1
;
switch
(
s
->
pix_fmt
){
case
PIX_FMT_YUV420P
:
case
PIX_FMT_YUV422
:
case
PIX_FMT_YUV422P
:
case
PIX_FMT_YUV444P
:
case
PIX_FMT_GRAY8
:
case
PIX_FMT_YUVJ420P
:
case
PIX_FMT_YUVJ422P
:
case
PIX_FMT_YUVJ444P
:
w_align
=
16
;
//FIXME check for non mpeg style codecs and use less alignment
h_align
=
16
;
break
;
case
PIX_FMT_YUV411P
:
w_align
=
32
;
h_align
=
8
;
break
;
case
PIX_FMT_YUV410P
:
if
(
s
->
codec_id
==
CODEC_ID_SVQ1
){
w_align
=
64
;
h_align
=
64
;
}
break
;
default
:
w_align
=
1
;
h_align
=
1
;
break
;
}
*
width
=
ALIGN
(
*
width
,
w_align
);
*
height
=
ALIGN
(
*
height
,
h_align
);
}
int
avcodec_default_get_buffer
(
AVCodecContext
*
s
,
AVFrame
*
pic
){
int
i
;
const
int
width
=
s
->
width
;
const
int
height
=
s
->
height
;
int
w
=
s
->
width
;
int
h
=
s
->
height
;
InternalBuffer
*
buf
;
assert
(
pic
->
data
[
0
]
==
NULL
);
...
...
@@ -153,10 +191,11 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
pic
->
age
=
pic
->
coded_picture_number
-
buf
->
last_pic_num
;
buf
->
last_pic_num
=
pic
->
coded_picture_number
;
}
else
{
int
align
,
h_chroma_shift
,
v_chroma_shift
;
int
w
,
h
,
pixel_size
;
int
h_chroma_shift
,
v_chroma_shift
;
int
s_align
,
pixel_size
;
avcodec_get_chroma_sub_sample
(
s
->
pix_fmt
,
&
h_chroma_shift
,
&
v_chroma_shift
);
switch
(
s
->
pix_fmt
){
case
PIX_FMT_RGB555
:
case
PIX_FMT_RGB565
:
...
...
@@ -173,13 +212,14 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
default
:
pixel_size
=
1
;
}
if
(
s
->
codec_id
==
CODEC_ID_SVQ1
)
align
=
63
;
else
align
=
15
;
w
=
(
width
+
align
)
&~
align
;
h
=
(
height
+
align
)
&~
align
;
avcodec_align_dimensions
(
s
,
&
w
,
&
h
);
#if defined(ARCH_POWERPC) || defined(HAVE_MMI) //FIXME some cleaner check
s_align
=
16
;
#else
s_align
=
8
;
#endif
if
(
!
(
s
->
flags
&
CODEC_FLAG_EMU_EDGE
)){
w
+=
EDGE_WIDTH
*
2
;
h
+=
EDGE_WIDTH
*
2
;
...
...
@@ -191,7 +231,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
const
int
h_shift
=
i
==
0
?
0
:
h_chroma_shift
;
const
int
v_shift
=
i
==
0
?
0
:
v_chroma_shift
;
pic
->
linesize
[
i
]
=
pixel_size
*
w
>>
h_shift
;
pic
->
linesize
[
i
]
=
ALIGN
(
pixel_size
*
w
>>
h_shift
,
s_align
)
;
buf
->
base
[
i
]
=
av_mallocz
((
pic
->
linesize
[
i
]
*
h
>>
v_shift
)
+
16
);
//FIXME 16
if
(
buf
->
base
[
i
]
==
NULL
)
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