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
38313626
Commit
38313626
authored
Apr 05, 2014
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avconv: do not use the stream codec context for encoding
parent
41776ba9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
58 deletions
+69
-58
avconv.c
avconv.c
+49
-42
avconv.h
avconv.h
+1
-0
avconv_filter.c
avconv_filter.c
+4
-4
avconv_opt.c
avconv_opt.c
+15
-12
No files found.
avconv.c
View file @
38313626
This diff is collapsed.
Click to expand it.
avconv.h
View file @
38313626
...
@@ -314,6 +314,7 @@ typedef struct OutputStream {
...
@@ -314,6 +314,7 @@ typedef struct OutputStream {
/* dts of the last packet sent to the muxer */
/* dts of the last packet sent to the muxer */
int64_t
last_mux_dts
;
int64_t
last_mux_dts
;
AVBitStreamFilterContext
*
bitstream_filters
;
AVBitStreamFilterContext
*
bitstream_filters
;
AVCodecContext
*
enc_ctx
;
AVCodec
*
enc
;
AVCodec
*
enc
;
int64_t
max_frames
;
int64_t
max_frames
;
AVFrame
*
filtered_frame
;
AVFrame
*
filtered_frame
;
...
...
avconv_filter.c
View file @
38313626
...
@@ -39,8 +39,8 @@
...
@@ -39,8 +39,8 @@
#define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name) \
#define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name) \
static char *choose_ ## var ## s(OutputStream *ost) \
static char *choose_ ## var ## s(OutputStream *ost) \
{ \
{ \
if (ost->
st->codec->var != none) {
\
if (ost->
enc_ctx->var != none) {
\
get_name(ost->
st->codec->var);
\
get_name(ost->
enc_ctx->var);
\
return av_strdup(name); \
return av_strdup(name); \
} else if (ost->enc && ost->enc->supported_list) { \
} else if (ost->enc && ost->enc->supported_list) { \
const type *p; \
const type *p; \
...
@@ -231,7 +231,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
...
@@ -231,7 +231,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
char
*
pix_fmts
;
char
*
pix_fmts
;
OutputStream
*
ost
=
ofilter
->
ost
;
OutputStream
*
ost
=
ofilter
->
ost
;
OutputFile
*
of
=
output_files
[
ost
->
file_index
];
OutputFile
*
of
=
output_files
[
ost
->
file_index
];
AVCodecContext
*
codec
=
ost
->
st
->
codec
;
AVCodecContext
*
codec
=
ost
->
enc_ctx
;
AVFilterContext
*
last_filter
=
out
->
filter_ctx
;
AVFilterContext
*
last_filter
=
out
->
filter_ctx
;
int
pad_idx
=
out
->
pad_idx
;
int
pad_idx
=
out
->
pad_idx
;
int
ret
;
int
ret
;
...
@@ -319,7 +319,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
...
@@ -319,7 +319,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
{
{
OutputStream
*
ost
=
ofilter
->
ost
;
OutputStream
*
ost
=
ofilter
->
ost
;
OutputFile
*
of
=
output_files
[
ost
->
file_index
];
OutputFile
*
of
=
output_files
[
ost
->
file_index
];
AVCodecContext
*
codec
=
ost
->
st
->
codec
;
AVCodecContext
*
codec
=
ost
->
enc_ctx
;
AVFilterContext
*
last_filter
=
out
->
filter_ctx
;
AVFilterContext
*
last_filter
=
out
->
filter_ctx
;
int
pad_idx
=
out
->
pad_idx
;
int
pad_idx
=
out
->
pad_idx
;
char
*
sample_fmts
,
*
sample_rates
,
*
channel_layouts
;
char
*
sample_fmts
,
*
sample_rates
,
*
channel_layouts
;
...
...
avconv_opt.c
View file @
38313626
...
@@ -905,6 +905,14 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
...
@@ -905,6 +905,14 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
ost
->
st
=
st
;
ost
->
st
=
st
;
st
->
codec
->
codec_type
=
type
;
st
->
codec
->
codec_type
=
type
;
choose_encoder
(
o
,
oc
,
ost
);
choose_encoder
(
o
,
oc
,
ost
);
ost
->
enc_ctx
=
avcodec_alloc_context3
(
ost
->
enc
);
if
(
!
ost
->
enc_ctx
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error allocating the encoding context.
\n
"
);
exit_program
(
1
);
}
ost
->
enc_ctx
->
codec_type
=
type
;
if
(
ost
->
enc
)
{
if
(
ost
->
enc
)
{
AVIOContext
*
s
=
NULL
;
AVIOContext
*
s
=
NULL
;
char
*
buf
=
NULL
,
*
arg
=
NULL
,
*
preset
=
NULL
;
char
*
buf
=
NULL
,
*
arg
=
NULL
,
*
preset
=
NULL
;
...
@@ -939,9 +947,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
...
@@ -939,9 +947,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
ost
->
encoder_opts
=
filter_codec_opts
(
o
->
g
->
codec_opts
,
AV_CODEC_ID_NONE
,
oc
,
st
,
NULL
);
ost
->
encoder_opts
=
filter_codec_opts
(
o
->
g
->
codec_opts
,
AV_CODEC_ID_NONE
,
oc
,
st
,
NULL
);
}
}
avcodec_get_context_defaults3
(
st
->
codec
,
ost
->
enc
);
st
->
codec
->
codec_type
=
type
;
// XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy
ost
->
max_frames
=
INT64_MAX
;
ost
->
max_frames
=
INT64_MAX
;
MATCH_PER_STREAM_OPT
(
max_frames
,
i64
,
ost
->
max_frames
,
oc
,
st
);
MATCH_PER_STREAM_OPT
(
max_frames
,
i64
,
ost
->
max_frames
,
oc
,
st
);
...
@@ -967,17 +972,17 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
...
@@ -967,17 +972,17 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
uint32_t
tag
=
strtol
(
codec_tag
,
&
next
,
0
);
uint32_t
tag
=
strtol
(
codec_tag
,
&
next
,
0
);
if
(
*
next
)
if
(
*
next
)
tag
=
AV_RL32
(
codec_tag
);
tag
=
AV_RL32
(
codec_tag
);
st
->
codec
->
codec_tag
=
tag
;
ost
->
enc_ctx
->
codec_tag
=
tag
;
}
}
MATCH_PER_STREAM_OPT
(
qscale
,
dbl
,
qscale
,
oc
,
st
);
MATCH_PER_STREAM_OPT
(
qscale
,
dbl
,
qscale
,
oc
,
st
);
if
(
qscale
>=
0
)
{
if
(
qscale
>=
0
)
{
st
->
codec
->
flags
|=
CODEC_FLAG_QSCALE
;
ost
->
enc_ctx
->
flags
|=
CODEC_FLAG_QSCALE
;
st
->
codec
->
global_quality
=
FF_QP2LAMBDA
*
qscale
;
ost
->
enc_ctx
->
global_quality
=
FF_QP2LAMBDA
*
qscale
;
}
}
if
(
oc
->
oformat
->
flags
&
AVFMT_GLOBALHEADER
)
if
(
oc
->
oformat
->
flags
&
AVFMT_GLOBALHEADER
)
st
->
codec
->
flags
|=
CODEC_FLAG_GLOBAL_HEADER
;
ost
->
enc_ctx
->
flags
|=
CODEC_FLAG_GLOBAL_HEADER
;
av_opt_get_int
(
o
->
g
->
sws_opts
,
"sws_flags"
,
0
,
&
ost
->
sws_flags
);
av_opt_get_int
(
o
->
g
->
sws_opts
,
"sws_flags"
,
0
,
&
ost
->
sws_flags
);
...
@@ -1068,7 +1073,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
...
@@ -1068,7 +1073,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
ost
=
new_output_stream
(
o
,
oc
,
AVMEDIA_TYPE_VIDEO
);
ost
=
new_output_stream
(
o
,
oc
,
AVMEDIA_TYPE_VIDEO
);
st
=
ost
->
st
;
st
=
ost
->
st
;
video_enc
=
st
->
codec
;
video_enc
=
ost
->
enc_ctx
;
MATCH_PER_STREAM_OPT
(
frame_aspect_ratios
,
str
,
frame_aspect_ratio
,
oc
,
st
);
MATCH_PER_STREAM_OPT
(
frame_aspect_ratios
,
str
,
frame_aspect_ratio
,
oc
,
st
);
if
(
frame_aspect_ratio
)
if
(
frame_aspect_ratio
)
...
@@ -1189,7 +1194,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc)
...
@@ -1189,7 +1194,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc)
ost
=
new_output_stream
(
o
,
oc
,
AVMEDIA_TYPE_AUDIO
);
ost
=
new_output_stream
(
o
,
oc
,
AVMEDIA_TYPE_AUDIO
);
st
=
ost
->
st
;
st
=
ost
->
st
;
audio_enc
=
st
->
codec
;
audio_enc
=
ost
->
enc_ctx
;
audio_enc
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
audio_enc
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
if
(
!
ost
->
stream_copy
)
{
if
(
!
ost
->
stream_copy
)
{
...
@@ -1237,13 +1242,11 @@ static OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *o
...
@@ -1237,13 +1242,11 @@ static OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *o
static
OutputStream
*
new_subtitle_stream
(
OptionsContext
*
o
,
AVFormatContext
*
oc
)
static
OutputStream
*
new_subtitle_stream
(
OptionsContext
*
o
,
AVFormatContext
*
oc
)
{
{
AVStream
*
st
;
OutputStream
*
ost
;
OutputStream
*
ost
;
AVCodecContext
*
subtitle_enc
;
AVCodecContext
*
subtitle_enc
;
ost
=
new_output_stream
(
o
,
oc
,
AVMEDIA_TYPE_SUBTITLE
);
ost
=
new_output_stream
(
o
,
oc
,
AVMEDIA_TYPE_SUBTITLE
);
st
=
ost
->
st
;
subtitle_enc
=
ost
->
enc_ctx
;
subtitle_enc
=
st
->
codec
;
subtitle_enc
->
codec_type
=
AVMEDIA_TYPE_SUBTITLE
;
subtitle_enc
->
codec_type
=
AVMEDIA_TYPE_SUBTITLE
;
...
...
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