| @@ -555,7 +555,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) · 554 unmodified lines |
| 555 | return AV_PIX_FMT_NONE; | 555 | return AV_PIX_FMT_NONE; |
| 556 | } | 556 | } |
| 557 | | 557 | |
| 558 | ret = avcodec_get_supported_config(ost->enc_ctx, NULL, AV_CODEC_CONFIG_PIX_FORMAT, | 558 | ret = avcodec_get_supported_config(ost->enc->enc_ctx, NULL, AV_CODEC_CONFIG_PIX_FORMAT, |
| 559 | 0, (const void **) &fmts, NULL); | 559 | 0, (const void **) &fmts, NULL); |
| 560 | if (ret < 0) | 560 | if (ret < 0) |
| 561 | return AV_PIX_FMT_NONE; | 561 | return AV_PIX_FMT_NONE; |
| @@ -587,7 +587,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) · 25 unmodified lines |
| 587 | } | 587 | } |
| 588 | | 588 | |
| 589 | if (fmts && !fmt_in_list(fmts, fmt)) | 589 | if (fmts && !fmt_in_list(fmts, fmt)) |
| 590 | fmt = choose_pixel_fmt(ost->enc_ctx, fmt); | 590 | fmt = choose_pixel_fmt(ost->enc->enc_ctx, fmt); |
| 591 | | 591 | |
| 592 | return fmt; | 592 | return fmt; |
| 593 | } | 593 | } |
| @@ -632,8 +632,8 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 38 unmodified lines |
| 632 | ost->frame_aspect_ratio = q; | 632 | ost->frame_aspect_ratio = q; |
| 633 | } | 633 | } |
| 634 | | 634 | |
| 635 | if (ost->enc_ctx) { | 635 | if (ost->enc) { |
| 636 | AVCodecContext *video_enc = ost->enc_ctx; | 636 | AVCodecContext *video_enc = ost->enc->enc_ctx; |
| 637 | const char *p = NULL, *fps_mode = NULL; | 637 | const char *p = NULL, *fps_mode = NULL; |
| 638 | const char *frame_size = NULL; | 638 | const char *frame_size = NULL; |
| 639 | const char *frame_pix_fmt = NULL; | 639 | const char *frame_pix_fmt = NULL; |
| @@ -746,10 +746,10 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 106 unmodified lines |
| 746 | ost->logfile_prefix ? ost->logfile_prefix : | 746 | ost->logfile_prefix ? ost->logfile_prefix : |
| 747 | DEFAULT_PASS_LOGFILENAME_PREFIX, | 747 | DEFAULT_PASS_LOGFILENAME_PREFIX, |
| 748 | ost_idx); | 748 | ost_idx); |
| 749 | if (!strcmp(ost->enc_ctx->codec->name, "libx264") || !strcmp(ost->enc_ctx->codec->name, "libvvenc")) { | 749 | if (!strcmp(video_enc->codec->name, "libx264") || !strcmp(video_enc->codec->name, "libvvenc")) { |
| 750 | if (av_opt_is_set_to_default_by_name(ost->enc_ctx, "stats", | 750 | if (av_opt_is_set_to_default_by_name(video_enc, "stats", |
| 751 | AV_OPT_SEARCH_CHILDREN) > 0) | 751 | AV_OPT_SEARCH_CHILDREN) > 0) |
| 752 | av_opt_set(ost->enc_ctx, "stats", logfilename, | 752 | av_opt_set(video_enc, "stats", logfilename, |
| 753 | AV_OPT_SEARCH_CHILDREN); | 753 | AV_OPT_SEARCH_CHILDREN); |
| 754 | } else { | 754 | } else { |
| 755 | if (video_enc->flags & AV_CODEC_FLAG_PASS2) { | 755 | if (video_enc->flags & AV_CODEC_FLAG_PASS2) { |
| @@ -842,8 +842,8 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o, · 86 unmodified lines |
| 842 | AVFormatContext *oc = mux->fc; | 842 | AVFormatContext *oc = mux->fc; |
| 843 | AVStream *st = ost->st; | 843 | AVStream *st = ost->st; |
| 844 | | 844 | |
| 845 | if (ost->enc_ctx) { | 845 | if (ost->enc) { |
| 846 | AVCodecContext *audio_enc = ost->enc_ctx; | 846 | AVCodecContext *audio_enc = ost->enc->enc_ctx; |
| 847 | int channels = 0; | 847 | int channels = 0; |
| 848 | const char *layout = NULL; | 848 | const char *layout = NULL; |
| 849 | const char *sample_fmt = NULL; | 849 | const char *sample_fmt = NULL; |
| @@ -881,8 +881,8 @@ static int new_stream_subtitle(Muxer *mux, const OptionsContext *o, · 31 unmodified lines |
| 881 | | 881 | |
| 882 | st = ost->st; | 882 | st = ost->st; |
| 883 | | 883 | |
| 884 | if (ost->enc_ctx) { | 884 | if (ost->enc) { |
| 885 | AVCodecContext *subtitle_enc = ost->enc_ctx; | 885 | AVCodecContext *subtitle_enc = ost->enc->enc_ctx; |
| 886 | | 886 | |
| 887 | AVCodecDescriptor const *input_descriptor = | 887 | AVCodecDescriptor const *input_descriptor = |
| 888 | avcodec_descriptor_get(ost->ist->par->codec_id); | 888 | avcodec_descriptor_get(ost->ist->par->codec_id); |
| @@ -923,7 +923,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, · 34 unmodified lines |
| 923 | const ViewSpecifier *vs) | 923 | const ViewSpecifier *vs) |
| 924 | { | 924 | { |
| 925 | OutputStream *ost = &ms->ost; | 925 | OutputStream *ost = &ms->ost; |
| 926 | AVCodecContext *enc_ctx = ost->enc_ctx; | 926 | AVCodecContext *enc_ctx = ost->enc->enc_ctx; |
| 927 | char name[16]; | 927 | char name[16]; |
| 928 | int ret; | 928 | int ret; |
| 929 | | 929 | |
| @@ -1245,10 +1245,6 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 315 unmodified lines |
| 1245 | } | 1245 | } |
| 1246 | | 1246 | |
| 1247 | if (enc) { | 1247 | if (enc) { |
| 1248 | ost->enc_ctx = avcodec_alloc_context3(enc); | | |
| 1249 | if (!ost->enc_ctx) | | |
| 1250 | return AVERROR(ENOMEM); | | |
| 1251 | | | |
| 1252 | ret = sch_add_enc(mux->sch, encoder_thread, ost, | 1248 | ret = sch_add_enc(mux->sch, encoder_thread, ost, |
| 1253 | ost->type == AVMEDIA_TYPE_SUBTITLE ? NULL : enc_open); | 1249 | ost->type == AVMEDIA_TYPE_SUBTITLE ? NULL : enc_open); |
| 1254 | if (ret < 0) | 1250 | if (ret < 0) |
| @@ -1290,21 +1286,21 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 35 unmodified lines |
| 1290 | if (!ms->pkt) | 1286 | if (!ms->pkt) |
| 1291 | return AVERROR(ENOMEM); | 1287 | return AVERROR(ENOMEM); |
| 1292 | | 1288 | |
| 1293 | if (ost->enc_ctx) { | 1289 | if (ost->enc) { |
| 1294 | AVIOContext *s = NULL; | 1290 | AVIOContext *s = NULL; |
| 1295 | char *buf = NULL, *arg = NULL; | 1291 | char *buf = NULL, *arg = NULL; |
| 1296 | const char *enc_stats_pre = NULL, *enc_stats_post = NULL, *mux_stats = NULL; | 1292 | const char *enc_stats_pre = NULL, *enc_stats_post = NULL, *mux_stats = NULL; |
| 1297 | const char *enc_time_base = NULL, *preset = NULL; | 1293 | const char *enc_time_base = NULL, *preset = NULL; |
| 1298 | | 1294 | |
| 1299 | ret = filter_codec_opts(o->g->codec_opts, ost->enc_ctx->codec_id, | 1295 | ret = filter_codec_opts(o->g->codec_opts, enc->id, |
| 1300 | oc, st, ost->enc_ctx->codec, &encoder_opts, | 1296 | oc, st, enc, &encoder_opts, |
| 1301 | &mux->enc_opts_used); | 1297 | &mux->enc_opts_used); |
| 1302 | if (ret < 0) | 1298 | if (ret < 0) |
| 1303 | goto fail; | 1299 | goto fail; |
| 1304 | | 1300 | |
| 1305 | opt_match_per_stream_str(ost, &o->presets, oc, st, &preset); | 1301 | opt_match_per_stream_str(ost, &o->presets, oc, st, &preset); |
| 1306 | opt_match_per_stream_int(ost, &o->autoscale, oc, st, &autoscale); | 1302 | opt_match_per_stream_int(ost, &o->autoscale, oc, st, &autoscale); |
| 1307 | if (preset && (!(ret = get_preset_file_2(preset, ost->enc_ctx->codec->name, &s)))) { | 1303 | if (preset && (!(ret = get_preset_file_2(preset, enc->name, &s)))) { |
| 1308 | AVBPrint bprint; | 1304 | AVBPrint bprint; |
| 1309 | av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); | 1305 | av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); |
| 1310 | do { | 1306 | do { |
| @@ -1404,7 +1400,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 93 unmodified lines |
| 1404 | | 1400 | |
| 1405 | threads_manual = !!av_dict_get(encoder_opts, "threads", NULL, 0); | 1401 | threads_manual = !!av_dict_get(encoder_opts, "threads", NULL, 0); |
| 1406 | | 1402 | |
| 1407 | ret = av_opt_set_dict2(ost->enc_ctx, &encoder_opts, AV_OPT_SEARCH_CHILDREN); | 1403 | ret = av_opt_set_dict2(ost->enc->enc_ctx, &encoder_opts, AV_OPT_SEARCH_CHILDREN); |
| 1408 | if (ret < 0) { | 1404 | if (ret < 0) { |
| 1409 | av_log(ost, AV_LOG_ERROR, "Error applying encoder options: %s\n", | 1405 | av_log(ost, AV_LOG_ERROR, "Error applying encoder options: %s\n", |
| 1410 | av_err2str(ret)); | 1406 | av_err2str(ret)); |
| @@ -1417,7 +1413,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 6 unmodified lines |
| 1417 | | 1413 | |
| 1418 | // default to automatic thread count | 1414 | // default to automatic thread count |
| 1419 | if (!threads_manual) | 1415 | if (!threads_manual) |
| 1420 | ost->enc_ctx->thread_count = 0; | 1416 | ost->enc->enc_ctx->thread_count = 0; |
| 1421 | } else { | 1417 | } else { |
| 1422 | ret = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, | 1418 | ret = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, |
| 1423 | NULL, &encoder_opts, | 1419 | NULL, &encoder_opts, |
| @@ -1429,8 +1425,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 5 unmodified lines |
| 1429 | | 1425 | |
| 1430 | if (o->bitexact) { | 1426 | if (o->bitexact) { |
| 1431 | ost->bitexact = 1; | 1427 | ost->bitexact = 1; |
| 1432 | } else if (ost->enc_ctx) { | 1428 | } else if (ost->enc) { |
| 1433 | ost->bitexact = !!(ost->enc_ctx->flags & AV_CODEC_FLAG_BITEXACT); | 1429 | ost->bitexact = !!(ost->enc->enc_ctx->flags & AV_CODEC_FLAG_BITEXACT); |
| 1434 | } | 1430 | } |
| 1435 | | 1431 | |
| 1436 | if (enc) { | 1432 | if (enc) { |
| @@ -1482,14 +1478,14 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 45 unmodified lines |
| 1482 | } | 1478 | } |
| 1483 | ost->st->codecpar->codec_tag = tag; | 1479 | ost->st->codecpar->codec_tag = tag; |
| 1484 | ms->par_in->codec_tag = tag; | 1480 | ms->par_in->codec_tag = tag; |
| 1485 | if (ost->enc_ctx) | 1481 | if (ost->enc) |
| 1486 | ost->enc_ctx->codec_tag = tag; | 1482 | ost->enc->enc_ctx->codec_tag = tag; |
| 1487 | } | 1483 | } |
| 1488 | | 1484 | |
| 1489 | opt_match_per_stream_dbl(ost, &o->qscale, oc, st, &qscale); | 1485 | opt_match_per_stream_dbl(ost, &o->qscale, oc, st, &qscale); |
| 1490 | if (ost->enc_ctx && qscale >= 0) { | 1486 | if (ost->enc && qscale >= 0) { |
| 1491 | ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE; | 1487 | ost->enc->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE; |
| 1492 | ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; | 1488 | ost->enc->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; |
| 1493 | } | 1489 | } |
| 1494 | | 1490 | |
| 1495 | if (ms->sch_idx >= 0) { | 1491 | if (ms->sch_idx >= 0) { |
| @@ -1511,8 +1507,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 15 unmodified lines |
| 1511 | opt_match_per_stream_int(ost, &o->fix_sub_duration_heartbeat, | 1507 | opt_match_per_stream_int(ost, &o->fix_sub_duration_heartbeat, |
| 1512 | oc, st, &ost->fix_sub_duration_heartbeat); | 1508 | oc, st, &ost->fix_sub_duration_heartbeat); |
| 1513 | | 1509 | |
| 1514 | if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc_ctx) | 1510 | if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc) |
| 1515 | ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; | 1511 | ost->enc->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; |
| 1516 | | 1512 | |
| 1517 | opt_match_per_stream_int(ost, &o->copy_initial_nonkeyframes, | 1513 | opt_match_per_stream_int(ost, &o->copy_initial_nonkeyframes, |
| 1518 | oc, st, &ms->copy_initial_nonkeyframes); | 1514 | oc, st, &ms->copy_initial_nonkeyframes); |
| @@ -2047,7 +2043,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, · 528 unmodified lines |
| 2047 | int limit_frames = 0, limit_frames_av_enc = 0; | 2043 | int limit_frames = 0, limit_frames_av_enc = 0; |
| 2048 | | 2044 | |
| 2049 | #define IS_AV_ENC(ost, type) \ | 2045 | #define IS_AV_ENC(ost, type) \ |
| 2050 | (ost->enc_ctx && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) | 2046 | (ost->enc && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) |
| 2051 | #define IS_INTERLEAVED(type) (type != AVMEDIA_TYPE_ATTACHMENT) | 2047 | #define IS_INTERLEAVED(type) (type != AVMEDIA_TYPE_ATTACHMENT) |
| 2052 | | 2048 | |
| 2053 | for (int i = 0; i < oc->nb_streams; i++) { | 2049 | for (int i = 0; i < oc->nb_streams; i++) { |
| @@ -2059,8 +2055,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, · 5 unmodified lines |
| 2059 | | 2055 | |
| 2060 | nb_interleaved += IS_INTERLEAVED(type); | 2056 | nb_interleaved += IS_INTERLEAVED(type); |
| 2061 | nb_av_enc += IS_AV_ENC(ost, type); | 2057 | nb_av_enc += IS_AV_ENC(ost, type); |
| 2062 | nb_audio_fs += (ost->enc_ctx && type == AVMEDIA_TYPE_AUDIO && | 2058 | nb_audio_fs += (ost->enc && type == AVMEDIA_TYPE_AUDIO && |
| 2063 | !(ost->enc_ctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)); | 2059 | !(ost->enc->enc_ctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)); |
| 2064 | | 2060 | |
| 2065 | limit_frames |= ms->max_frames < INT64_MAX; | 2061 | limit_frames |= ms->max_frames < INT64_MAX; |
| 2066 | limit_frames_av_enc |= (ms->max_frames < INT64_MAX) && IS_AV_ENC(ost, type); | 2062 | limit_frames_av_enc |= (ms->max_frames < INT64_MAX) && IS_AV_ENC(ost, type); |
| @@ -3193,7 +3189,7 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o) · 1126 unmodified lines |
| 3193 | mux->fc, ost->st, &forced_keyframes); | 3189 | mux->fc, ost->st, &forced_keyframes); |
| 3194 | | 3190 | |
| 3195 | if (!(ost->type == AVMEDIA_TYPE_VIDEO && | 3191 | if (!(ost->type == AVMEDIA_TYPE_VIDEO && |
| 3196 | ost->enc_ctx && forced_keyframes)) | 3192 | ost->enc && forced_keyframes)) |
| 3197 | continue; | 3193 | continue; |
| 3198 | | 3194 | |
| 3199 | if (!strncmp(forced_keyframes, "expr:", 5)) { | 3195 | if (!strncmp(forced_keyframes, "expr:", 5)) { |