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
77b2cd7b
Commit
77b2cd7b
authored
Dec 25, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AVFrame: add side data.
parent
7ecc2d40
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
0 deletions
+110
-0
frame.c
libavutil/frame.c
+72
-0
frame.h
libavutil/frame.h
+38
-0
No files found.
libavutil/frame.c
View file @
77b2cd7b
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "audioconvert.h"
#include "audioconvert.h"
#include "buffer.h"
#include "buffer.h"
#include "common.h"
#include "common.h"
#include "dict.h"
#include "frame.h"
#include "frame.h"
#include "imgutils.h"
#include "imgutils.h"
#include "mem.h"
#include "mem.h"
...
@@ -273,6 +274,13 @@ void av_frame_unref(AVFrame *frame)
...
@@ -273,6 +274,13 @@ void av_frame_unref(AVFrame *frame)
{
{
int
i
;
int
i
;
for
(
i
=
0
;
i
<
frame
->
nb_side_data
;
i
++
)
{
av_freep
(
&
frame
->
side_data
[
i
]
->
data
);
av_dict_free
(
&
frame
->
side_data
[
i
]
->
metadata
);
av_freep
(
&
frame
->
side_data
[
i
]);
}
av_freep
(
&
frame
->
side_data
);
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
frame
->
buf
);
i
++
)
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
frame
->
buf
);
i
++
)
av_buffer_unref
(
&
frame
->
buf
[
i
]);
av_buffer_unref
(
&
frame
->
buf
[
i
]);
for
(
i
=
0
;
i
<
frame
->
nb_extended_buf
;
i
++
)
for
(
i
=
0
;
i
<
frame
->
nb_extended_buf
;
i
++
)
...
@@ -353,6 +361,8 @@ int av_frame_make_writable(AVFrame *frame)
...
@@ -353,6 +361,8 @@ int av_frame_make_writable(AVFrame *frame)
int
av_frame_copy_props
(
AVFrame
*
dst
,
const
AVFrame
*
src
)
int
av_frame_copy_props
(
AVFrame
*
dst
,
const
AVFrame
*
src
)
{
{
int
i
;
dst
->
key_frame
=
src
->
key_frame
;
dst
->
key_frame
=
src
->
key_frame
;
dst
->
pict_type
=
src
->
pict_type
;
dst
->
pict_type
=
src
->
pict_type
;
dst
->
sample_aspect_ratio
=
src
->
sample_aspect_ratio
;
dst
->
sample_aspect_ratio
=
src
->
sample_aspect_ratio
;
...
@@ -367,6 +377,23 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
...
@@ -367,6 +377,23 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
dst
->
coded_picture_number
=
src
->
coded_picture_number
;
dst
->
coded_picture_number
=
src
->
coded_picture_number
;
dst
->
display_picture_number
=
src
->
display_picture_number
;
dst
->
display_picture_number
=
src
->
display_picture_number
;
for
(
i
=
0
;
i
<
src
->
nb_side_data
;
i
++
)
{
const
AVFrameSideData
*
sd_src
=
src
->
side_data
[
i
];
AVFrameSideData
*
sd_dst
=
av_frame_new_side_data
(
dst
,
sd_src
->
type
,
sd_src
->
size
);
if
(
!
sd_dst
)
{
for
(
i
=
0
;
i
<
dst
->
nb_side_data
;
i
++
)
{
av_freep
(
&
dst
->
side_data
[
i
]
->
data
);
av_freep
(
&
dst
->
side_data
[
i
]);
av_dict_free
(
&
dst
->
side_data
[
i
]
->
metadata
);
}
av_freep
(
&
dst
->
side_data
);
return
AVERROR
(
ENOMEM
);
}
memcpy
(
sd_dst
->
data
,
sd_src
->
data
,
sd_src
->
size
);
av_dict_copy
(
&
sd_dst
->
metadata
,
sd_src
->
metadata
,
0
);
}
return
0
;
return
0
;
}
}
...
@@ -399,3 +426,48 @@ AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane)
...
@@ -399,3 +426,48 @@ AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane)
}
}
return
NULL
;
return
NULL
;
}
}
AVFrameSideData
*
av_frame_new_side_data
(
AVFrame
*
frame
,
enum
AVFrameSideDataType
type
,
int
size
)
{
AVFrameSideData
*
ret
,
**
tmp
;
if
(
frame
->
nb_side_data
>
INT_MAX
/
sizeof
(
*
frame
->
side_data
)
-
1
)
return
NULL
;
tmp
=
av_realloc
(
frame
->
side_data
,
(
frame
->
nb_side_data
+
1
)
*
sizeof
(
*
frame
->
side_data
));
if
(
!
tmp
)
return
NULL
;
frame
->
side_data
=
tmp
;
ret
=
av_mallocz
(
sizeof
(
*
ret
));
if
(
!
ret
)
return
NULL
;
ret
->
data
=
av_malloc
(
size
);
if
(
!
ret
->
data
)
{
av_freep
(
&
ret
);
return
NULL
;
}
ret
->
size
=
size
;
ret
->
type
=
type
;
frame
->
side_data
[
frame
->
nb_side_data
++
]
=
ret
;
return
ret
;
}
AVFrameSideData
*
av_frame_get_side_data
(
AVFrame
*
frame
,
enum
AVFrameSideDataType
type
)
{
int
i
;
for
(
i
=
0
;
i
<
frame
->
nb_side_data
;
i
++
)
{
if
(
frame
->
side_data
[
i
]
->
type
==
type
)
return
frame
->
side_data
[
i
];
}
return
NULL
;
}
libavutil/frame.h
View file @
77b2cd7b
...
@@ -26,9 +26,23 @@
...
@@ -26,9 +26,23 @@
#include "avutil.h"
#include "avutil.h"
#include "buffer.h"
#include "buffer.h"
#include "dict.h"
#include "rational.h"
#include "rational.h"
#include "samplefmt.h"
#include "samplefmt.h"
enum
AVFrameSideDataType
{
/**
* The data is the AVPanScan struct defined in libavcodec.
*/
AV_FRAME_DATA_PANSCAN
,
};
typedef
struct
AVFrameSideData
{
enum
AVFrameSideDataType
type
;
uint8_t
*
data
;
int
size
;
AVDictionary
*
metadata
;
}
AVFrameSideData
;
/**
/**
* This structure describes decoded (raw) audio or video data.
* This structure describes decoded (raw) audio or video data.
...
@@ -306,6 +320,9 @@ typedef struct AVFrame {
...
@@ -306,6 +320,9 @@ typedef struct AVFrame {
* Number of elements in extended_buf.
* Number of elements in extended_buf.
*/
*/
int
nb_extended_buf
;
int
nb_extended_buf
;
AVFrameSideData
**
side_data
;
int
nb_side_data
;
}
AVFrame
;
}
AVFrame
;
/**
/**
...
@@ -413,6 +430,7 @@ int av_frame_make_writable(AVFrame *frame);
...
@@ -413,6 +430,7 @@ int av_frame_make_writable(AVFrame *frame);
* Metadata for the purpose of this function are those fields that do not affect
* Metadata for the purpose of this function are those fields that do not affect
* the data layout in the buffers. E.g. pts, sample rate (for audio) or sample
* the data layout in the buffers. E.g. pts, sample rate (for audio) or sample
* aspect ratio (for video), but not width/height or channel layout.
* aspect ratio (for video), but not width/height or channel layout.
* Side data is also copied.
*/
*/
int
av_frame_copy_props
(
AVFrame
*
dst
,
const
AVFrame
*
src
);
int
av_frame_copy_props
(
AVFrame
*
dst
,
const
AVFrame
*
src
);
...
@@ -426,4 +444,24 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src);
...
@@ -426,4 +444,24 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src);
*/
*/
AVBufferRef
*
av_frame_get_plane_buffer
(
AVFrame
*
frame
,
int
plane
);
AVBufferRef
*
av_frame_get_plane_buffer
(
AVFrame
*
frame
,
int
plane
);
/**
* Add a new side data to a frame.
*
* @param frame a frame to which the side data should be added
* @param type type of the added side data
* @param size size of the side data
*
* @return newly added side data on success, NULL on error
*/
AVFrameSideData
*
av_frame_new_side_data
(
AVFrame
*
frame
,
enum
AVFrameSideDataType
type
,
int
size
);
/**
* @return a pointer to the side data of a given type on success, NULL if there
* is no side data with such type in this frame.
*/
AVFrameSideData
*
av_frame_get_side_data
(
AVFrame
*
frame
,
enum
AVFrameSideDataType
type
);
#endif
/* AVUTIL_FRAME_H */
#endif
/* AVUTIL_FRAME_H */
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