diff --git a/conf/vanilla/autoload_configs/av.conf.xml b/conf/vanilla/autoload_configs/av.conf.xml
new file mode 100644
index 0000000000..7d0390646a
--- /dev/null
+++ b/conf/vanilla/autoload_configs/av.conf.xml
@@ -0,0 +1,145 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mod/applications/mod_av/avcodec.c b/src/mod/applications/mod_av/avcodec.c
index cc1927a117..04dbf84b02 100644
--- a/src/mod/applications/mod_av/avcodec.c
+++ b/src/mod/applications/mod_av/avcodec.c
@@ -45,6 +45,8 @@ int SLICE_SIZE = SWITCH_DEFAULT_VIDEO_SIZE;
#define H263_MODE_B // else Mode A only
#define KEY_FRAME_MIN_FREQ 250000
+// #define DUMP_ENCODER_CTX
+
SWITCH_MODULE_LOAD_FUNCTION(mod_avcodec_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avcodec_shutdown);
@@ -103,6 +105,207 @@ const uint8_t *fs_avc_find_startcode(const uint8_t *p, const uint8_t *end){
return out;
}
+static void dump_encoder_ctx(AVCodecContext *ctx)
+{
+#ifdef DUMP_ENCODER_CTX
+#define STRINGIFY(x) #x
+#define my_dump_int(x) switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, STRINGIFY(x) " = %d\n", ctx->x);
+#define my_dump_int64(x) switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, STRINGIFY(x) " = % " SWITCH_INT64_T_FMT "\n", ctx->x);
+#define my_dump_float(x) switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, STRINGIFY(x) " = %f\n", ctx->x);
+#define my_dump_enum(x) switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, STRINGIFY(x) " = %d\n", ctx->x);
+#define my_dump_uint(x) switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, STRINGIFY(x) " = 0x%x\n", ctx->x);
+
+ my_dump_int(log_level_offset);
+ my_dump_enum(codec_type); /* see AVMEDIA_TYPE_xxx */
+ my_dump_enum(codec_id); /* see AV_CODEC_ID_xxx */
+ my_dump_int(codec_tag);
+ my_dump_int64(bit_rate);
+ my_dump_int(bit_rate_tolerance);
+ my_dump_int(global_quality);
+ my_dump_int(compression_level);
+ my_dump_uint(flags);
+ my_dump_uint(flags2);
+ my_dump_int(extradata_size);
+ my_dump_int(time_base.num);
+ my_dump_int(time_base.den);
+ my_dump_int(ticks_per_frame);
+ my_dump_int(delay);
+ my_dump_int(width);
+ my_dump_int(height);
+ my_dump_int(coded_width);
+ my_dump_int(coded_height);
+ my_dump_int(gop_size);
+ my_dump_enum(pix_fmt);
+ my_dump_int(max_b_frames);
+ my_dump_float(b_quant_factor);
+ my_dump_float(b_quant_offset);
+ my_dump_int(has_b_frames);
+ my_dump_float(i_quant_factor);
+ my_dump_float(i_quant_offset);
+ my_dump_float(lumi_masking);
+ my_dump_float(temporal_cplx_masking);
+ my_dump_float(spatial_cplx_masking);
+ my_dump_float(p_masking);
+ my_dump_float(dark_masking);
+ my_dump_int(slice_count);
+ my_dump_int(sample_aspect_ratio.num);
+ my_dump_int(sample_aspect_ratio.den);
+ my_dump_int(me_cmp);
+ my_dump_int(me_sub_cmp);
+ my_dump_int(mb_cmp);
+ my_dump_int(ildct_cmp);
+ my_dump_int(dia_size);
+ my_dump_int(last_predictor_count);
+ my_dump_int(me_pre_cmp);
+ my_dump_int(pre_dia_size);
+ my_dump_int(me_subpel_quality);
+ my_dump_int(me_range);
+ my_dump_uint(slice_flags);
+ my_dump_int(mb_decision);
+ my_dump_int(scenechange_threshold);
+ my_dump_int(noise_reduction);
+ // my_dump_int(me_threshold);
+ // my_dump_int(mb_threshold);
+ my_dump_int(intra_dc_precision);
+ my_dump_int(skip_top);
+ my_dump_int(skip_bottom);
+ my_dump_int(mb_lmin);
+ my_dump_int(mb_lmax);
+ my_dump_int(me_penalty_compensation);
+ my_dump_int(bidir_refine);
+ my_dump_int(brd_scale);
+ my_dump_int(keyint_min);
+ my_dump_int(refs);
+ my_dump_int(chromaoffset);
+ my_dump_int(mv0_threshold);
+ my_dump_int(b_sensitivity);
+ my_dump_enum(color_primaries);
+ my_dump_enum(color_trc);
+ my_dump_enum(colorspace);
+ my_dump_enum(color_range);
+ my_dump_enum(chroma_sample_location);
+ my_dump_int(slices);
+ my_dump_enum(field_order);
+ my_dump_int(sample_rate); ///< samples per second
+ my_dump_int(channels); ///< number of audio channels
+ my_dump_enum(sample_fmt); ///< sample format
+ my_dump_int(frame_size);
+ my_dump_int(frame_number);
+ my_dump_int(block_align);
+ my_dump_int(cutoff);
+ my_dump_int64(channel_layout);
+ my_dump_int64(request_channel_layout);
+ my_dump_enum(audio_service_type);
+ my_dump_enum(request_sample_fmt);
+ my_dump_int(refcounted_frames);
+ my_dump_float(qcompress); ///< amount of qscale change between easy & hard scenes (0.0-1.0)
+ my_dump_float(qblur); ///< amount of qscale smoothing over time (0.0-1.0)
+ my_dump_int(qmin);
+ my_dump_int(qmax);
+ my_dump_int(max_qdiff);
+ my_dump_int(rc_buffer_size);
+ my_dump_int(rc_override_count);
+ my_dump_int64(rc_max_rate);
+ my_dump_int64(rc_min_rate);
+ my_dump_float(rc_max_available_vbv_use);
+ my_dump_float(rc_min_vbv_overflow_use);
+ my_dump_int(rc_initial_buffer_occupancy);
+ my_dump_int(trellis);
+ my_dump_int(workaround_bugs);
+ my_dump_int(strict_std_compliance);
+ my_dump_int(error_concealment);
+ my_dump_int(debug);
+ my_dump_int(debug_mv);
+ my_dump_int(err_recognition);
+ my_dump_int64(reordered_opaque);
+ my_dump_int(dct_algo);
+ my_dump_int(idct_algo);
+ my_dump_int(bits_per_coded_sample);
+ my_dump_int(bits_per_raw_sample);
+ my_dump_int(lowres);
+ my_dump_int(thread_count);
+ my_dump_int(thread_type);
+ my_dump_int(active_thread_type);
+ my_dump_int(thread_safe_callbacks);
+ my_dump_int(nsse_weight);
+ my_dump_int(profile);
+ my_dump_int(level);
+ my_dump_enum(skip_loop_filter);
+ my_dump_enum(skip_idct);
+ my_dump_enum(skip_frame);
+ my_dump_int(subtitle_header_size);
+ my_dump_int(initial_padding);
+ my_dump_int(framerate.num);
+ my_dump_int(framerate.den);
+ my_dump_enum(sw_pix_fmt);
+ my_dump_int(pkt_timebase.num);
+ my_dump_int(pkt_timebase.den);
+ my_dump_int(lowres);
+ my_dump_int64(pts_correction_num_faulty_pts); /// Number of incorrect PTS values so far
+ my_dump_int64(pts_correction_num_faulty_dts); /// Number of incorrect DTS values so far
+ my_dump_int64(pts_correction_last_pts); /// PTS of the last frame
+ my_dump_int64(pts_correction_last_dts); /// DTS of the last frame
+ my_dump_int(sub_charenc_mode);
+ my_dump_int(skip_alpha);
+ my_dump_int(seek_preroll);
+ my_dump_int(debug_mv);
+ my_dump_int(sub_text_format);
+ my_dump_int(trailing_padding);
+ my_dump_int64(max_pixels);
+ my_dump_int(hwaccel_flags);
+ my_dump_int(apply_cropping);
+
+#if 0
+ // depracated
+ my_dump_int(rc_strategy);
+ my_dump_int(b_frame_strategy);
+ my_dump_int(prediction_method);
+ my_dump_int(pre_me);
+ my_dump_int(intra_quant_bias);
+ my_dump_int(inter_quant_bias);
+ my_dump_int(xvmc_acceleration);
+ my_dump_int(scenechange_factor);
+ my_dump_float(rc_qsquish);
+ my_dump_float(rc_qmod_amp);
+ my_dump_int(rc_qmod_freq);
+ my_dump_float(rc_buffer_aggressivity);
+ my_dump_float(rc_initial_cplx);
+ my_dump_int(coder_type);
+ my_dump_int(context_model);
+ // my_dump_int(lmin);
+ // my_dump_int(lmax);
+ my_dump_int(frame_skip_threshold);
+ my_dump_int(frame_skip_factor);
+ my_dump_int(frame_skip_exp);
+ my_dump_int(frame_skip_cmp);
+ my_dump_int(min_prediction_order);
+ my_dump_int(max_prediction_order);
+ my_dump_int64(timecode_frame_start);
+ my_dump_int(rtp_payload_size);
+ my_dump_int(mv_bits);
+ my_dump_int(header_bits);
+ my_dump_int(i_tex_bits);
+ my_dump_int(p_tex_bits);
+ my_dump_int(i_count);
+ my_dump_int(p_count);
+ my_dump_int(skip_count);
+ my_dump_int(misc_bits);
+ my_dump_int(frame_bits);
+ // my_dump_int64(vbv_delay);
+ my_dump_int(side_data_only_packets);
+#endif
+
+
+#undef my_dump_int
+#undef my_dump_int64
+#undef my_dump_float
+#undef my_dump_enum
+#undef my_dump_uint
+
+#endif
+}
+
+
/* RFC 2190 MODE A
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -195,7 +398,11 @@ typedef struct h264_codec_context_s {
int hw_encoder;
} h264_codec_context_t;
-static uint8_t ff_input_buffer_padding[FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };
+#ifndef AV_INPUT_BUFFER_PADDING_SIZE
+#define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
+#endif
+
+static uint8_t ff_input_buffer_padding[AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
#define MAX_CODECS 4
@@ -1034,6 +1241,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
}
+ {
+ char buf[1024];
+
+ avcodec_string(buf, sizeof(buf), context->encoder_ctx, 0);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s\n", buf);
+ }
+
+ dump_encoder_ctx(context->encoder_ctx);
+
if (avcodec_open2(context->encoder_ctx, context->encoder, NULL) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open codec\n");
return SWITCH_STATUS_FALSE;
@@ -1642,10 +1858,13 @@ static void load_config()
profile->ctx.qmin = -1;
profile->ctx.qmax = -1;
profile->ctx.max_qdiff = -1;
+ profile->ctx.thread_count = switch_parse_cpu_string("cpu/2/4");
+ profile->decoder_thread_count = switch_parse_cpu_string("cpu/2/4");
if (!strcasecmp(CODEC_MAPS[i], "H264")) {
profile->ctx.profile = FF_PROFILE_H264_BASELINE;
profile->ctx.level = 41;
+ profile->ctx.flags |= (CODEC_FLAG_LOOP_FILTER | AV_CODEC_FLAG_PSNR);
}
}