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
d1032180
Commit
d1032180
authored
Mar 31, 2010
by
Ronald S. Bultje
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add avcodec_copy_context().
Originally committed as revision 22750 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
e33f1fa0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
avcodec.h
libavcodec/avcodec.h
+13
-0
options.c
libavcodec/options.c
+60
-0
No files found.
libavcodec/avcodec.h
View file @
d1032180
...
...
@@ -3258,6 +3258,19 @@ AVCodecContext *avcodec_alloc_context(void);
* we WILL change its arguments and name a few times! */
AVCodecContext
*
avcodec_alloc_context2
(
enum
AVMediaType
);
/**
* Copy the settings of the source AVCodecContext into the destination
* AVCodecContext. The resulting destination codec context will be
* unopened, i.e. you are required to call avcodec_open() before you
* can use this AVCodecContext to decode/encode video/audio data.
*
* @param dest target codec context, should be initialized with
* avcodec_alloc_context(), but otherwise uninitialized
* @param src source codec context
* @return AVERROR() on error (e.g. memory allocation error), 0 on success
*/
int
avcodec_copy_context
(
AVCodecContext
*
dest
,
const
AVCodecContext
*
src
);
/**
* Sets the fields of the given AVFrame to default values.
*
...
...
libavcodec/options.c
View file @
d1032180
...
...
@@ -471,3 +471,63 @@ AVCodecContext *avcodec_alloc_context(void){
return
avcodec_alloc_context2
(
AVMEDIA_TYPE_UNKNOWN
);
}
int
avcodec_copy_context
(
AVCodecContext
*
dest
,
const
AVCodecContext
*
src
)
{
if
(
dest
->
codec
)
{
// check that the dest context is uninitialized
av_log
(
dest
,
AV_LOG_ERROR
,
"Tried to copy AVCodecContext %p into already-initialized %p
\n
"
,
src
,
dest
);
return
AVERROR
(
EINVAL
);
}
memcpy
(
dest
,
src
,
sizeof
(
*
dest
));
/* set values specific to opened codecs back to their default state */
dest
->
priv_data
=
NULL
;
dest
->
codec
=
NULL
;
dest
->
palctrl
=
NULL
;
dest
->
slice_offset
=
NULL
;
dest
->
internal_buffer
=
NULL
;
dest
->
hwaccel
=
NULL
;
dest
->
execute
=
NULL
;
dest
->
execute2
=
NULL
;
dest
->
reget_buffer
=
NULL
;
dest
->
thread_opaque
=
NULL
;
/* reallocate values that should be allocated separately */
dest
->
rc_eq
=
NULL
;
dest
->
extradata
=
NULL
;
dest
->
intra_matrix
=
NULL
;
dest
->
inter_matrix
=
NULL
;
dest
->
rc_override
=
NULL
;
if
(
src
->
rc_eq
)
{
dest
->
rc_eq
=
av_strdup
(
src
->
rc_eq
);
if
(
!
dest
->
rc_eq
)
return
AVERROR
(
ENOMEM
);
}
#define alloc_and_copy_or_fail(obj, size, pad) \
if (src->obj && size > 0) { \
dest->obj = av_malloc(size + pad); \
if (!dest->obj) \
goto fail; \
memcpy(dest->obj, src->obj, size); \
if (pad) \
memset(((uint8_t *) dest->obj) + size, 0, pad); \
}
alloc_and_copy_or_fail
(
extradata
,
src
->
extradata_size
,
FF_INPUT_BUFFER_PADDING_SIZE
);
alloc_and_copy_or_fail
(
intra_matrix
,
64
*
sizeof
(
int16_t
),
0
);
alloc_and_copy_or_fail
(
inter_matrix
,
64
*
sizeof
(
int16_t
),
0
);
alloc_and_copy_or_fail
(
rc_override
,
src
->
rc_override_count
*
sizeof
(
*
src
->
rc_override
),
0
);
#undef alloc_and_copy_or_fail
return
0
;
fail
:
av_freep
(
&
dest
->
rc_override
);
av_freep
(
&
dest
->
intra_matrix
);
av_freep
(
&
dest
->
inter_matrix
);
av_freep
(
&
dest
->
extradata
);
av_freep
(
&
dest
->
rc_eq
);
return
AVERROR
(
ENOMEM
);
}
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