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
589a6042
Commit
589a6042
authored
Mar 23, 2015
by
Ronald S. Bultje
Committed by
Michael Niedermayer
Mar 25, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avutil: make AVFrameSideData buffers ref-counted.
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
b8e36690
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
15 deletions
+39
-15
frame.c
libavutil/frame.c
+38
-15
frame.h
libavutil/frame.h
+1
-0
No files found.
libavutil/frame.c
View file @
589a6042
...
@@ -115,7 +115,7 @@ static void free_side_data(AVFrameSideData **ptr_sd)
...
@@ -115,7 +115,7 @@ static void free_side_data(AVFrameSideData **ptr_sd)
{
{
AVFrameSideData
*
sd
=
*
ptr_sd
;
AVFrameSideData
*
sd
=
*
ptr_sd
;
av_
freep
(
&
sd
->
data
);
av_
buffer_unref
(
&
sd
->
buf
);
av_dict_free
(
&
sd
->
metadata
);
av_dict_free
(
&
sd
->
metadata
);
av_freep
(
ptr_sd
);
av_freep
(
ptr_sd
);
}
}
...
@@ -275,7 +275,7 @@ int av_frame_get_buffer(AVFrame *frame, int align)
...
@@ -275,7 +275,7 @@ int av_frame_get_buffer(AVFrame *frame, int align)
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
int
av_frame_copy_props
(
AVFrame
*
dst
,
const
AVFrame
*
src
)
static
int
frame_copy_props
(
AVFrame
*
dst
,
const
AVFrame
*
src
,
int
force_copy
)
{
{
int
i
;
int
i
;
...
@@ -320,6 +320,7 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
...
@@ -320,6 +320,7 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
if
(
sd_src
->
type
==
AV_FRAME_DATA_PANSCAN
if
(
sd_src
->
type
==
AV_FRAME_DATA_PANSCAN
&&
(
src
->
width
!=
dst
->
width
||
src
->
height
!=
dst
->
height
))
&&
(
src
->
width
!=
dst
->
width
||
src
->
height
!=
dst
->
height
))
continue
;
continue
;
if
(
force_copy
)
{
sd_dst
=
av_frame_new_side_data
(
dst
,
sd_src
->
type
,
sd_dst
=
av_frame_new_side_data
(
dst
,
sd_src
->
type
,
sd_src
->
size
);
sd_src
->
size
);
if
(
!
sd_dst
)
{
if
(
!
sd_dst
)
{
...
@@ -327,6 +328,20 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
...
@@ -327,6 +328,20 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
}
}
memcpy
(
sd_dst
->
data
,
sd_src
->
data
,
sd_src
->
size
);
memcpy
(
sd_dst
->
data
,
sd_src
->
data
,
sd_src
->
size
);
}
else
{
sd_dst
=
av_frame_new_side_data
(
dst
,
sd_src
->
type
,
0
);
if
(
!
sd_dst
)
{
wipe_side_data
(
dst
);
return
AVERROR
(
ENOMEM
);
}
sd_dst
->
buf
=
av_buffer_ref
(
sd_src
->
buf
);
if
(
!
sd_dst
->
buf
)
{
wipe_side_data
(
dst
);
return
AVERROR
(
ENOMEM
);
}
sd_dst
->
data
=
sd_dst
->
buf
->
data
;
sd_dst
->
size
=
sd_dst
->
buf
->
size
;
}
av_dict_copy
(
&
sd_dst
->
metadata
,
sd_src
->
metadata
,
0
);
av_dict_copy
(
&
sd_dst
->
metadata
,
sd_src
->
metadata
,
0
);
}
}
...
@@ -356,7 +371,7 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src)
...
@@ -356,7 +371,7 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src)
dst
->
channel_layout
=
src
->
channel_layout
;
dst
->
channel_layout
=
src
->
channel_layout
;
dst
->
nb_samples
=
src
->
nb_samples
;
dst
->
nb_samples
=
src
->
nb_samples
;
ret
=
av_frame_copy_props
(
dst
,
src
);
ret
=
frame_copy_props
(
dst
,
src
,
0
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
...
@@ -530,6 +545,11 @@ int av_frame_make_writable(AVFrame *frame)
...
@@ -530,6 +545,11 @@ int av_frame_make_writable(AVFrame *frame)
return
0
;
return
0
;
}
}
int
av_frame_copy_props
(
AVFrame
*
dst
,
const
AVFrame
*
src
)
{
return
frame_copy_props
(
dst
,
src
,
1
);
}
AVBufferRef
*
av_frame_get_plane_buffer
(
AVFrame
*
frame
,
int
plane
)
AVBufferRef
*
av_frame_get_plane_buffer
(
AVFrame
*
frame
,
int
plane
)
{
{
uint8_t
*
data
;
uint8_t
*
data
;
...
@@ -580,13 +600,16 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
...
@@ -580,13 +600,16 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
if
(
!
ret
)
if
(
!
ret
)
return
NULL
;
return
NULL
;
ret
->
data
=
av_malloc
(
size
);
if
(
size
>
0
)
{
if
(
!
ret
->
data
)
{
ret
->
buf
=
av_buffer_alloc
(
size
);
if
(
!
ret
->
buf
)
{
av_freep
(
&
ret
);
av_freep
(
&
ret
);
return
NULL
;
return
NULL
;
}
}
ret
->
data
=
ret
->
buf
->
data
;
ret
->
size
=
size
;
ret
->
size
=
size
;
}
ret
->
type
=
type
;
ret
->
type
=
type
;
frame
->
side_data
[
frame
->
nb_side_data
++
]
=
ret
;
frame
->
side_data
[
frame
->
nb_side_data
++
]
=
ret
;
...
...
libavutil/frame.h
View file @
589a6042
...
@@ -136,6 +136,7 @@ typedef struct AVFrameSideData {
...
@@ -136,6 +136,7 @@ typedef struct AVFrameSideData {
uint8_t
*
data
;
uint8_t
*
data
;
int
size
;
int
size
;
AVDictionary
*
metadata
;
AVDictionary
*
metadata
;
AVBufferRef
*
buf
;
}
AVFrameSideData
;
}
AVFrameSideData
;
/**
/**
...
...
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