MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / add_codec

Function add_codec

ffserver.c:3824–3896  ·  view source on GitHub ↗

add a codec and set the default parameters */

Source from the content-addressed store, hash-verified

3822
3823/* add a codec and set the default parameters */
3824static void add_codec(FFStream *stream, AVCodecContext *av)
3825{
3826 AVStream *st;
3827
3828 /* compute default parameters */
3829 switch(av->codec_type) {
3830 case AVMEDIA_TYPE_AUDIO:
3831 if (av->bit_rate == 0)
3832 av->bit_rate = 64000;
3833 if (av->sample_rate == 0)
3834 av->sample_rate = 22050;
3835 if (av->channels == 0)
3836 av->channels = 1;
3837 break;
3838 case AVMEDIA_TYPE_VIDEO:
3839 if (av->bit_rate == 0)
3840 av->bit_rate = 64000;
3841 if (av->time_base.num == 0){
3842 av->time_base.den = 5;
3843 av->time_base.num = 1;
3844 }
3845 if (av->width == 0 || av->height == 0) {
3846 av->width = 160;
3847 av->height = 128;
3848 }
3849 /* Bitrate tolerance is less for streaming */
3850 if (av->bit_rate_tolerance == 0)
3851 av->bit_rate_tolerance = FFMAX(av->bit_rate / 4,
3852 (int64_t)av->bit_rate*av->time_base.num/av->time_base.den);
3853 if (av->qmin == 0)
3854 av->qmin = 3;
3855 if (av->qmax == 0)
3856 av->qmax = 31;
3857 if (av->max_qdiff == 0)
3858 av->max_qdiff = 3;
3859 av->qcompress = 0.5;
3860 av->qblur = 0.5;
3861
3862 if (!av->nsse_weight)
3863 av->nsse_weight = 8;
3864
3865 av->frame_skip_cmp = FF_CMP_DCTMAX;
3866 av->me_method = ME_EPZS;
3867 av->rc_buffer_aggressivity = 1.0;
3868
3869 if (!av->rc_eq)
3870 av->rc_eq = "tex^qComp";
3871 if (!av->i_quant_factor)
3872 av->i_quant_factor = -0.8;
3873 if (!av->b_quant_factor)
3874 av->b_quant_factor = 1.25;
3875 if (!av->b_quant_offset)
3876 av->b_quant_offset = 1.25;
3877 if (!av->rc_max_rate)
3878 av->rc_max_rate = av->bit_rate * 2;
3879
3880 if (av->rc_max_rate && !av->rc_buffer_size) {
3881 av->rc_buffer_size = av->rc_max_rate;

Callers 1

parse_ffconfigFunction · 0.85

Calls 2

av_malloczFunction · 0.85
avcodec_alloc_contextFunction · 0.85

Tested by

no test coverage detected