* commit '383136264ef40452efd86cafb2d7221cd3830b3d':
avconv: do not use the stream codec context for encoding
Conflicts:
ffmpeg.c
ffmpeg_opt.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -483,6 +483,8 @@ static void ffmpeg_cleanup(int ret) |
483 | 483 |
av_freep(&ost->avfilter); |
484 | 484 |
av_freep(&ost->logfile_prefix); |
485 | 485 |
|
486 |
+ avcodec_free_context(&ost->enc_ctx); |
|
487 |
+ |
|
486 | 488 |
av_freep(&output_streams[i]); |
487 | 489 |
} |
488 | 490 |
#if HAVE_PTHREADS |
... | ... |
@@ -573,7 +575,7 @@ static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, |
573 | 573 |
static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) |
574 | 574 |
{ |
575 | 575 |
AVBitStreamFilterContext *bsfc = ost->bitstream_filters; |
576 |
- AVCodecContext *avctx = ost->st->codec; |
|
576 |
+ AVCodecContext *avctx = ost->enc_ctx; |
|
577 | 577 |
int ret; |
578 | 578 |
|
579 | 579 |
if ((avctx->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method == VSYNC_DROP) || |
... | ... |
@@ -698,7 +700,7 @@ static int check_recording_time(OutputStream *ost) |
698 | 698 |
OutputFile *of = output_files[ost->file_index]; |
699 | 699 |
|
700 | 700 |
if (of->recording_time != INT64_MAX && |
701 |
- av_compare_ts(ost->sync_opts - ost->first_pts, ost->st->codec->time_base, of->recording_time, |
|
701 |
+ av_compare_ts(ost->sync_opts - ost->first_pts, ost->enc_ctx->time_base, of->recording_time, |
|
702 | 702 |
AV_TIME_BASE_Q) >= 0) { |
703 | 703 |
close_output_stream(ost); |
704 | 704 |
return 0; |
... | ... |
@@ -709,7 +711,7 @@ static int check_recording_time(OutputStream *ost) |
709 | 709 |
static void do_audio_out(AVFormatContext *s, OutputStream *ost, |
710 | 710 |
AVFrame *frame) |
711 | 711 |
{ |
712 |
- AVCodecContext *enc = ost->st->codec; |
|
712 |
+ AVCodecContext *enc = ost->enc_ctx; |
|
713 | 713 |
AVPacket pkt; |
714 | 714 |
int got_packet = 0; |
715 | 715 |
|
... | ... |
@@ -778,7 +780,7 @@ static void do_subtitle_out(AVFormatContext *s, |
778 | 778 |
return; |
779 | 779 |
} |
780 | 780 |
|
781 |
- enc = ost->st->codec; |
|
781 |
+ enc = ost->enc_ctx; |
|
782 | 782 |
|
783 | 783 |
if (!subtitle_out) { |
784 | 784 |
subtitle_out = av_malloc(subtitle_out_max_size); |
... | ... |
@@ -842,7 +844,7 @@ static void do_video_out(AVFormatContext *s, |
842 | 842 |
{ |
843 | 843 |
int ret, format_video_sync; |
844 | 844 |
AVPacket pkt; |
845 |
- AVCodecContext *enc = ost->st->codec; |
|
845 |
+ AVCodecContext *enc = ost->enc_ctx; |
|
846 | 846 |
int nb_frames, i; |
847 | 847 |
double sync_ipts, delta; |
848 | 848 |
double duration = 0; |
... | ... |
@@ -959,7 +961,7 @@ static void do_video_out(AVFormatContext *s, |
959 | 959 |
int got_packet, forced_keyframe = 0; |
960 | 960 |
double pts_time; |
961 | 961 |
|
962 |
- if (ost->st->codec->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) && |
|
962 |
+ if (enc->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) && |
|
963 | 963 |
ost->top_field_first >= 0) |
964 | 964 |
in_picture->top_field_first = !!ost->top_field_first; |
965 | 965 |
|
... | ... |
@@ -971,7 +973,7 @@ static void do_video_out(AVFormatContext *s, |
971 | 971 |
} else |
972 | 972 |
enc->field_order = AV_FIELD_PROGRESSIVE; |
973 | 973 |
|
974 |
- in_picture->quality = ost->st->codec->global_quality; |
|
974 |
+ in_picture->quality = enc->global_quality; |
|
975 | 975 |
if (!enc->me_threshold) |
976 | 976 |
in_picture->pict_type = 0; |
977 | 977 |
|
... | ... |
@@ -1092,7 +1094,7 @@ static void do_video_stats(OutputStream *ost, int frame_size) |
1092 | 1092 |
} |
1093 | 1093 |
} |
1094 | 1094 |
|
1095 |
- enc = ost->st->codec; |
|
1095 |
+ enc = ost->enc_ctx; |
|
1096 | 1096 |
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { |
1097 | 1097 |
frame_number = ost->st->nb_frames; |
1098 | 1098 |
fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame->quality / (float)FF_QP2LAMBDA); |
... | ... |
@@ -1130,7 +1132,7 @@ static int reap_filters(void) |
1130 | 1130 |
OutputStream *ost = output_streams[i]; |
1131 | 1131 |
OutputFile *of = output_files[ost->file_index]; |
1132 | 1132 |
AVFilterContext *filter; |
1133 |
- AVCodecContext *enc = ost->st->codec; |
|
1133 |
+ AVCodecContext *enc = ost->enc_ctx; |
|
1134 | 1134 |
int ret = 0; |
1135 | 1135 |
|
1136 | 1136 |
if (!ost->filter) |
... | ... |
@@ -1212,13 +1214,13 @@ static void print_final_stats(int64_t total_size) |
1212 | 1212 |
|
1213 | 1213 |
for (i = 0; i < nb_output_streams; i++) { |
1214 | 1214 |
OutputStream *ost = output_streams[i]; |
1215 |
- switch (ost->st->codec->codec_type) { |
|
1215 |
+ switch (ost->enc_ctx->codec_type) { |
|
1216 | 1216 |
case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break; |
1217 | 1217 |
case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break; |
1218 | 1218 |
case AVMEDIA_TYPE_SUBTITLE: subtitle_size += ost->data_size; break; |
1219 | 1219 |
default: other_size += ost->data_size; break; |
1220 | 1220 |
} |
1221 |
- extra_size += ost->st->codec->extradata_size; |
|
1221 |
+ extra_size += ost->enc_ctx->extradata_size; |
|
1222 | 1222 |
data_size += ost->data_size; |
1223 | 1223 |
} |
1224 | 1224 |
|
... | ... |
@@ -1282,7 +1284,7 @@ static void print_final_stats(int64_t total_size) |
1282 | 1282 |
|
1283 | 1283 |
for (j = 0; j < of->ctx->nb_streams; j++) { |
1284 | 1284 |
OutputStream *ost = output_streams[of->ost_index + j]; |
1285 |
- enum AVMediaType type = ost->st->codec->codec_type; |
|
1285 |
+ enum AVMediaType type = ost->enc_ctx->codec_type; |
|
1286 | 1286 |
|
1287 | 1287 |
total_size += ost->data_size; |
1288 | 1288 |
total_packets += ost->packets_written; |
... | ... |
@@ -1352,7 +1354,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti |
1352 | 1352 |
for (i = 0; i < nb_output_streams; i++) { |
1353 | 1353 |
float q = -1; |
1354 | 1354 |
ost = output_streams[i]; |
1355 |
- enc = ost->st->codec; |
|
1355 |
+ enc = ost->enc_ctx; |
|
1356 | 1356 |
if (!ost->stream_copy && enc->coded_frame) |
1357 | 1357 |
q = enc->coded_frame->quality / (float)FF_QP2LAMBDA; |
1358 | 1358 |
if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { |
... | ... |
@@ -1482,23 +1484,23 @@ static void flush_encoders(void) |
1482 | 1482 |
|
1483 | 1483 |
for (i = 0; i < nb_output_streams; i++) { |
1484 | 1484 |
OutputStream *ost = output_streams[i]; |
1485 |
- AVCodecContext *enc = ost->st->codec; |
|
1485 |
+ AVCodecContext *enc = ost->enc_ctx; |
|
1486 | 1486 |
AVFormatContext *os = output_files[ost->file_index]->ctx; |
1487 | 1487 |
int stop_encoding = 0; |
1488 | 1488 |
|
1489 | 1489 |
if (!ost->encoding_needed) |
1490 | 1490 |
continue; |
1491 | 1491 |
|
1492 |
- if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1) |
|
1492 |
+ if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1) |
|
1493 | 1493 |
continue; |
1494 |
- if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == AV_CODEC_ID_RAWVIDEO) |
|
1494 |
+ if (enc->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == AV_CODEC_ID_RAWVIDEO) |
|
1495 | 1495 |
continue; |
1496 | 1496 |
|
1497 | 1497 |
for (;;) { |
1498 | 1498 |
int (*encode)(AVCodecContext*, AVPacket*, const AVFrame*, int*) = NULL; |
1499 | 1499 |
const char *desc; |
1500 | 1500 |
|
1501 |
- switch (ost->st->codec->codec_type) { |
|
1501 |
+ switch (enc->codec_type) { |
|
1502 | 1502 |
case AVMEDIA_TYPE_AUDIO: |
1503 | 1503 |
encode = avcodec_encode_audio2; |
1504 | 1504 |
desc = "Audio"; |
... | ... |
@@ -1619,7 +1621,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p |
1619 | 1619 |
} |
1620 | 1620 |
|
1621 | 1621 |
/* force the input stream PTS */ |
1622 |
- if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) |
|
1622 |
+ if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) |
|
1623 | 1623 |
ost->sync_opts++; |
1624 | 1624 |
|
1625 | 1625 |
if (pkt->pts != AV_NOPTS_VALUE) |
... | ... |
@@ -1646,10 +1648,10 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p |
1646 | 1646 |
opkt.flags = pkt->flags; |
1647 | 1647 |
|
1648 | 1648 |
// FIXME remove the following 2 lines they shall be replaced by the bitstream filters |
1649 |
- if ( ost->st->codec->codec_id != AV_CODEC_ID_H264 |
|
1650 |
- && ost->st->codec->codec_id != AV_CODEC_ID_MPEG1VIDEO |
|
1651 |
- && ost->st->codec->codec_id != AV_CODEC_ID_MPEG2VIDEO |
|
1652 |
- && ost->st->codec->codec_id != AV_CODEC_ID_VC1 |
|
1649 |
+ if ( ost->enc_ctx->codec_id != AV_CODEC_ID_H264 |
|
1650 |
+ && ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG1VIDEO |
|
1651 |
+ && ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG2VIDEO |
|
1652 |
+ && ost->enc_ctx->codec_id != AV_CODEC_ID_VC1 |
|
1653 | 1653 |
) { |
1654 | 1654 |
if (av_parser_change(ost->parser, ost->st->codec, |
1655 | 1655 |
&opkt.data, &opkt.size, |
... | ... |
@@ -1791,7 +1793,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) |
1791 | 1791 |
if (ost->enc->type == AVMEDIA_TYPE_AUDIO && |
1792 | 1792 |
!(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) |
1793 | 1793 |
av_buffersink_set_frame_size(ost->filter->filter, |
1794 |
- ost->st->codec->frame_size); |
|
1794 |
+ ost->enc_ctx->frame_size); |
|
1795 | 1795 |
} |
1796 | 1796 |
} |
1797 | 1797 |
} |
... | ... |
@@ -2462,7 +2464,7 @@ static int transcode_init(void) |
2462 | 2462 |
if (ost->attachment_filename) |
2463 | 2463 |
continue; |
2464 | 2464 |
|
2465 |
- enc_ctx = ost->st->codec; |
|
2465 |
+ enc_ctx = ost->enc_ctx; |
|
2466 | 2466 |
|
2467 | 2467 |
if (ist) { |
2468 | 2468 |
dec_ctx = ist->dec_ctx; |
... | ... |
@@ -2739,7 +2741,7 @@ static int transcode_init(void) |
2739 | 2739 |
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] = NAN; |
2740 | 2740 |
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] = NAN; |
2741 | 2741 |
} else { |
2742 |
- parse_forced_key_frames(ost->forced_keyframes, ost, ost->st->codec); |
|
2742 |
+ parse_forced_key_frames(ost->forced_keyframes, ost, ost->enc_ctx); |
|
2743 | 2743 |
} |
2744 | 2744 |
} |
2745 | 2745 |
break; |
... | ... |
@@ -2801,17 +2803,19 @@ static int transcode_init(void) |
2801 | 2801 |
dec = ist->dec_ctx; |
2802 | 2802 |
if (dec && dec->subtitle_header) { |
2803 | 2803 |
/* ASS code assumes this buffer is null terminated so add extra byte. */ |
2804 |
- ost->st->codec->subtitle_header = av_mallocz(dec->subtitle_header_size + 1); |
|
2805 |
- if (!ost->st->codec->subtitle_header) { |
|
2804 |
+ ost->enc_ctx->subtitle_header = av_mallocz(dec->subtitle_header_size + 1); |
|
2805 |
+ if (!ost->enc_ctx->subtitle_header) { |
|
2806 | 2806 |
ret = AVERROR(ENOMEM); |
2807 | 2807 |
goto dump_format; |
2808 | 2808 |
} |
2809 |
- memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); |
|
2810 |
- ost->st->codec->subtitle_header_size = dec->subtitle_header_size; |
|
2809 |
+ memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); |
|
2810 |
+ ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size; |
|
2811 | 2811 |
} |
2812 | 2812 |
if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0)) |
2813 | 2813 |
av_dict_set(&ost->encoder_opts, "threads", "auto", 0); |
2814 |
- if ((ret = avcodec_open2(ost->st->codec, codec, &ost->encoder_opts)) < 0) { |
|
2814 |
+ av_dict_set(&ost->encoder_opts, "side_data_only_packets", "1", 0); |
|
2815 |
+ |
|
2816 |
+ if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) { |
|
2815 | 2817 |
if (ret == AVERROR_EXPERIMENTAL) |
2816 | 2818 |
abort_codec_experimental(codec, 1); |
2817 | 2819 |
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height", |
... | ... |
@@ -2821,13 +2825,20 @@ static int transcode_init(void) |
2821 | 2821 |
if (ost->enc->type == AVMEDIA_TYPE_AUDIO && |
2822 | 2822 |
!(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) |
2823 | 2823 |
av_buffersink_set_frame_size(ost->filter->filter, |
2824 |
- ost->st->codec->frame_size); |
|
2824 |
+ ost->enc_ctx->frame_size); |
|
2825 | 2825 |
assert_avoptions(ost->encoder_opts); |
2826 |
- if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) |
|
2826 |
+ if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000) |
|
2827 | 2827 |
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." |
2828 | 2828 |
" It takes bits/s as argument, not kbits/s\n"); |
2829 | 2829 |
} else { |
2830 |
- av_opt_set_dict(ost->st->codec, &ost->encoder_opts); |
|
2830 |
+ av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts); |
|
2831 |
+ } |
|
2832 |
+ |
|
2833 |
+ ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); |
|
2834 |
+ if (ret < 0) { |
|
2835 |
+ av_log(NULL, AV_LOG_FATAL, |
|
2836 |
+ "Error initializing the output stream codec context.\n"); |
|
2837 |
+ exit_program(1); |
|
2831 | 2838 |
} |
2832 | 2839 |
} |
2833 | 2840 |
|
... | ... |
@@ -2836,7 +2847,7 @@ static int transcode_init(void) |
2836 | 2836 |
if ((ret = init_input_stream(i, error, sizeof(error))) < 0) { |
2837 | 2837 |
for (i = 0; i < nb_output_streams; i++) { |
2838 | 2838 |
ost = output_streams[i]; |
2839 |
- avcodec_close(ost->st->codec); |
|
2839 |
+ avcodec_close(ost->enc_ctx); |
|
2840 | 2840 |
} |
2841 | 2841 |
goto dump_format; |
2842 | 2842 |
} |
... | ... |
@@ -3618,8 +3629,7 @@ static int transcode(void) |
3618 | 3618 |
for (i = 0; i < nb_output_streams; i++) { |
3619 | 3619 |
ost = output_streams[i]; |
3620 | 3620 |
if (ost->encoding_needed) { |
3621 |
- av_freep(&ost->st->codec->stats_in); |
|
3622 |
- avcodec_close(ost->st->codec); |
|
3621 |
+ av_freep(&ost->enc_ctx->stats_in); |
|
3623 | 3622 |
} |
3624 | 3623 |
} |
3625 | 3624 |
|
... | ... |
@@ -3645,13 +3655,10 @@ static int transcode(void) |
3645 | 3645 |
for (i = 0; i < nb_output_streams; i++) { |
3646 | 3646 |
ost = output_streams[i]; |
3647 | 3647 |
if (ost) { |
3648 |
- if (ost->stream_copy) |
|
3649 |
- av_freep(&ost->st->codec->extradata); |
|
3650 | 3648 |
if (ost->logfile) { |
3651 | 3649 |
fclose(ost->logfile); |
3652 | 3650 |
ost->logfile = NULL; |
3653 | 3651 |
} |
3654 |
- av_freep(&ost->st->codec->subtitle_header); |
|
3655 | 3652 |
av_freep(&ost->forced_kf_pts); |
3656 | 3653 |
av_freep(&ost->apad); |
3657 | 3654 |
av_dict_free(&ost->encoder_opts); |
... | ... |
@@ -378,6 +378,7 @@ typedef struct OutputStream { |
378 | 378 |
/* dts of the last packet sent to the muxer */ |
379 | 379 |
int64_t last_mux_dts; |
380 | 380 |
AVBitStreamFilterContext *bitstream_filters; |
381 |
+ AVCodecContext *enc_ctx; |
|
381 | 382 |
AVCodec *enc; |
382 | 383 |
int64_t max_frames; |
383 | 384 |
AVFrame *filtered_frame; |
... | ... |
@@ -149,8 +149,8 @@ static char *choose_pix_fmts(OutputStream *ost) |
149 | 149 |
#define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name) \ |
150 | 150 |
static char *choose_ ## var ## s(OutputStream *ost) \ |
151 | 151 |
{ \ |
152 |
- if (ost->st->codec->var != none) { \ |
|
153 |
- get_name(ost->st->codec->var); \ |
|
152 |
+ if (ost->enc_ctx->var != none) { \ |
|
153 |
+ get_name(ost->enc_ctx->var); \ |
|
154 | 154 |
return av_strdup(name); \ |
155 | 155 |
} else if (ost->enc && ost->enc->supported_list) { \ |
156 | 156 |
const type *p; \ |
... | ... |
@@ -344,7 +344,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, |
344 | 344 |
char *pix_fmts; |
345 | 345 |
OutputStream *ost = ofilter->ost; |
346 | 346 |
OutputFile *of = output_files[ost->file_index]; |
347 |
- AVCodecContext *codec = ost->st->codec; |
|
347 |
+ AVCodecContext *codec = ost->enc_ctx; |
|
348 | 348 |
AVFilterContext *last_filter = out->filter_ctx; |
349 | 349 |
int pad_idx = out->pad_idx; |
350 | 350 |
int ret; |
... | ... |
@@ -434,7 +434,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, |
434 | 434 |
{ |
435 | 435 |
OutputStream *ost = ofilter->ost; |
436 | 436 |
OutputFile *of = output_files[ost->file_index]; |
437 |
- AVCodecContext *codec = ost->st->codec; |
|
437 |
+ AVCodecContext *codec = ost->enc_ctx; |
|
438 | 438 |
AVFilterContext *last_filter = out->filter_ctx; |
439 | 439 |
int pad_idx = out->pad_idx; |
440 | 440 |
char *sample_fmts, *sample_rates, *channel_layouts; |
... | ... |
@@ -1065,6 +1065,14 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e |
1065 | 1065 |
ost->st = st; |
1066 | 1066 |
st->codec->codec_type = type; |
1067 | 1067 |
choose_encoder(o, oc, ost); |
1068 |
+ |
|
1069 |
+ ost->enc_ctx = avcodec_alloc_context3(ost->enc); |
|
1070 |
+ if (!ost->enc_ctx) { |
|
1071 |
+ av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n"); |
|
1072 |
+ exit_program(1); |
|
1073 |
+ } |
|
1074 |
+ ost->enc_ctx->codec_type = type; |
|
1075 |
+ |
|
1068 | 1076 |
if (ost->enc) { |
1069 | 1077 |
AVIOContext *s = NULL; |
1070 | 1078 |
char *buf = NULL, *arg = NULL, *preset = NULL; |
... | ... |
@@ -1099,9 +1107,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e |
1099 | 1099 |
ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL); |
1100 | 1100 |
} |
1101 | 1101 |
|
1102 |
- avcodec_get_context_defaults3(st->codec, ost->enc); |
|
1103 |
- st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy |
|
1104 |
- |
|
1105 | 1102 |
ost->max_frames = INT64_MAX; |
1106 | 1103 |
MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st); |
1107 | 1104 |
for (i = 0; i<o->nb_max_frames; i++) { |
... | ... |
@@ -1137,17 +1142,17 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e |
1137 | 1137 |
uint32_t tag = strtol(codec_tag, &next, 0); |
1138 | 1138 |
if (*next) |
1139 | 1139 |
tag = AV_RL32(codec_tag); |
1140 |
- st->codec->codec_tag = tag; |
|
1140 |
+ ost->enc_ctx->codec_tag = tag; |
|
1141 | 1141 |
} |
1142 | 1142 |
|
1143 | 1143 |
MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st); |
1144 | 1144 |
if (qscale >= 0) { |
1145 |
- st->codec->flags |= CODEC_FLAG_QSCALE; |
|
1146 |
- st->codec->global_quality = FF_QP2LAMBDA * qscale; |
|
1145 |
+ ost->enc_ctx->flags |= CODEC_FLAG_QSCALE; |
|
1146 |
+ ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; |
|
1147 | 1147 |
} |
1148 | 1148 |
|
1149 | 1149 |
if (oc->oformat->flags & AVFMT_GLOBALHEADER) |
1150 |
- st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; |
|
1150 |
+ ost->enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; |
|
1151 | 1151 |
|
1152 | 1152 |
av_opt_get_int(o->g->sws_opts, "sws_flags", 0, &ost->sws_flags); |
1153 | 1153 |
|
... | ... |
@@ -1257,7 +1262,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in |
1257 | 1257 |
|
1258 | 1258 |
ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index); |
1259 | 1259 |
st = ost->st; |
1260 |
- video_enc = st->codec; |
|
1260 |
+ video_enc = ost->enc_ctx; |
|
1261 | 1261 |
|
1262 | 1262 |
MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st); |
1263 | 1263 |
if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) { |
... | ... |
@@ -1418,7 +1423,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in |
1418 | 1418 |
ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index); |
1419 | 1419 |
st = ost->st; |
1420 | 1420 |
|
1421 |
- audio_enc = st->codec; |
|
1421 |
+ audio_enc = ost->enc_ctx; |
|
1422 | 1422 |
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO; |
1423 | 1423 |
|
1424 | 1424 |
MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); |
... | ... |
@@ -1508,7 +1513,7 @@ static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, |
1508 | 1508 |
|
1509 | 1509 |
ost = new_output_stream(o, oc, AVMEDIA_TYPE_SUBTITLE, source_index); |
1510 | 1510 |
st = ost->st; |
1511 |
- subtitle_enc = st->codec; |
|
1511 |
+ subtitle_enc = ost->enc_ctx; |
|
1512 | 1512 |
|
1513 | 1513 |
subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE; |
1514 | 1514 |
|