static void add_codec(FFServerStream *stream, AVCodecContext *av)

{

    AVStream *st;



    if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))

        return;



    /* compute default parameters */

    switch(av->codec_type) {

    case AVMEDIA_TYPE_AUDIO:

        if (av->bit_rate == 0)

            av->bit_rate = 64000;

        if (av->sample_rate == 0)

            av->sample_rate = 22050;

        if (av->channels == 0)

            av->channels = 1;

        break;

    case AVMEDIA_TYPE_VIDEO:

        if (av->bit_rate == 0)

            av->bit_rate = 64000;

        if (av->time_base.num == 0){

            av->time_base.den = 5;

            av->time_base.num = 1;

        }

        if (av->width == 0 || av->height == 0) {

            av->width = 160;

            av->height = 128;

        }

        /* Bitrate tolerance is less for streaming */

        if (av->bit_rate_tolerance == 0)

            av->bit_rate_tolerance = FFMAX(av->bit_rate / 4,

                      (int64_t)av->bit_rate*av->time_base.num/av->time_base.den);

        if (av->qmin == 0)

            av->qmin = 3;

        if (av->qmax == 0)

            av->qmax = 31;

        if (av->max_qdiff == 0)

            av->max_qdiff = 3;

        av->qcompress = 0.5;

        av->qblur = 0.5;



        if (!av->nsse_weight)

            av->nsse_weight = 8;



        av->frame_skip_cmp = FF_CMP_DCTMAX;

        if (!av->me_method)

            av->me_method = ME_EPZS;

        av->rc_buffer_aggressivity = 1.0;



        if (!av->rc_eq)

            av->rc_eq = av_strdup("tex^qComp");

        if (!av->i_quant_factor)

            av->i_quant_factor = -0.8;

        if (!av->b_quant_factor)

            av->b_quant_factor = 1.25;

        if (!av->b_quant_offset)

            av->b_quant_offset = 1.25;

        if (!av->rc_max_rate)

            av->rc_max_rate = av->bit_rate * 2;



        if (av->rc_max_rate && !av->rc_buffer_size) {

            av->rc_buffer_size = av->rc_max_rate;

        }





        break;

    default:

        abort();

    }



    st = av_mallocz(sizeof(AVStream));

    if (!st)

        return;

    st->codec = avcodec_alloc_context3(NULL);

    stream->streams[stream->nb_streams++] = st;

    memcpy(st->codec, av, sizeof(AVCodecContext));

}

static void add_codec(FFServerStream *stream, AVCodecContext *av)

{

    AVStream *st;



    if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))

        return;



    

    switch(av->codec_type) {

    case AVMEDIA_TYPE_AUDIO:

        if (av->bit_rate == 0)

            av->bit_rate = 64000;

        if (av->sample_rate == 0)

            av->sample_rate = 22050;

        if (av->channels == 0)

            av->channels = 1;

        break;

    case AVMEDIA_TYPE_VIDEO:

        if (av->bit_rate == 0)

            av->bit_rate = 64000;

        if (av->time_base.num == 0){

            av->time_base.den = 5;

            av->time_base.num = 1;

        }

        if (av->width == 0 || av->height == 0) {

            av->width = 160;

            av->height = 128;

        }

        

        if (av->bit_rate_tolerance == 0)

            av->bit_rate_tolerance = FFMAX(av->bit_rate / 4,

                      (int64_t)av->bit_rate*av->time_base.num/av->time_base.den);

        if (av->qmin == 0)

            av->qmin = 3;

        if (av->qmax == 0)

            av->qmax = 31;

        if (av->max_qdiff == 0)

            av->max_qdiff = 3;

        av->qcompress = 0.5;

        av->qblur = 0.5;



        if (!av->nsse_weight)

            av->nsse_weight = 8;



        av->frame_skip_cmp = FF_CMP_DCTMAX;

        if (!av->me_method)

            av->me_method = ME_EPZS;

        av->rc_buffer_aggressivity = 1.0;



        if (!av->rc_eq)

            av->rc_eq = av_strdup("tex^qComp");

        if (!av->i_quant_factor)

            av->i_quant_factor = -0.8;

        if (!av->b_quant_factor)

            av->b_quant_factor = 1.25;

        if (!av->b_quant_offset)

            av->b_quant_offset = 1.25;

        if (!av->rc_max_rate)

            av->rc_max_rate = av->bit_rate * 2;



        if (av->rc_max_rate && !av->rc_buffer_size) {

            av->rc_buffer_size = av->rc_max_rate;

        }





        break;

    default:

        abort();

    }



    st = av_mallocz(sizeof(AVStream));

    if (!st)

        return;

    st->codec = avcodec_alloc_context3(NULL);

    stream->streams[stream->nb_streams++] = st;

    memcpy(st->codec, av, sizeof(AVCodecContext));

}

static void FUNC_0(FFServerStream *VAR_0, AVCodecContext *VAR_1)

{

    AVStream *st;



    if(VAR_0->nb_streams >= FF_ARRAY_ELEMS(VAR_0->streams))

        return;



    

    switch(VAR_1->codec_type) {

    case AVMEDIA_TYPE_AUDIO:

        if (VAR_1->bit_rate == 0)

            VAR_1->bit_rate = 64000;

        if (VAR_1->sample_rate == 0)

            VAR_1->sample_rate = 22050;

        if (VAR_1->channels == 0)

            VAR_1->channels = 1;

        break;

    case AVMEDIA_TYPE_VIDEO:

        if (VAR_1->bit_rate == 0)

            VAR_1->bit_rate = 64000;

        if (VAR_1->time_base.num == 0){

            VAR_1->time_base.den = 5;

            VAR_1->time_base.num = 1;

        }

        if (VAR_1->width == 0 || VAR_1->height == 0) {

            VAR_1->width = 160;

            VAR_1->height = 128;

        }

        

        if (VAR_1->bit_rate_tolerance == 0)

            VAR_1->bit_rate_tolerance = FFMAX(VAR_1->bit_rate / 4,

                      (int64_t)VAR_1->bit_rate*VAR_1->time_base.num/VAR_1->time_base.den);

        if (VAR_1->qmin == 0)

            VAR_1->qmin = 3;

        if (VAR_1->qmax == 0)

            VAR_1->qmax = 31;

        if (VAR_1->max_qdiff == 0)

            VAR_1->max_qdiff = 3;

        VAR_1->qcompress = 0.5;

        VAR_1->qblur = 0.5;



        if (!VAR_1->nsse_weight)

            VAR_1->nsse_weight = 8;



        VAR_1->frame_skip_cmp = FF_CMP_DCTMAX;

        if (!VAR_1->me_method)

            VAR_1->me_method = ME_EPZS;

        VAR_1->rc_buffer_aggressivity = 1.0;



        if (!VAR_1->rc_eq)

            VAR_1->rc_eq = av_strdup("tex^qComp");

        if (!VAR_1->i_quant_factor)

            VAR_1->i_quant_factor = -0.8;

        if (!VAR_1->b_quant_factor)

            VAR_1->b_quant_factor = 1.25;

        if (!VAR_1->b_quant_offset)

            VAR_1->b_quant_offset = 1.25;

        if (!VAR_1->rc_max_rate)

            VAR_1->rc_max_rate = VAR_1->bit_rate * 2;



        if (VAR_1->rc_max_rate && !VAR_1->rc_buffer_size) {

            VAR_1->rc_buffer_size = VAR_1->rc_max_rate;

        }





        break;

    default:

        abort();

    }



    st = av_mallocz(sizeof(AVStream));

    if (!st)

        return;

    st->codec = avcodec_alloc_context3(NULL);

    VAR_0->streams[VAR_0->nb_streams++] = st;

    memcpy(st->codec, VAR_1, sizeof(AVCodecContext));

}

static void FUNC_0(FFServerStream *VAR_0, AVCodecContext *VAR_1)
{ AVStream *st; if(VAR_0->nb_streams >= FF_ARRAY_ELEMS(VAR_0->streams))
return; switch(VAR_1->codec_type) { case AVMEDIA_TYPE_AUDIO:
if (VAR_1->bit_rate == 0)
VAR_1->bit_rate = 64000; if (VAR_1->sample_rate == 0)
VAR_1->sample_rate = 22050; if (VAR_1->channels == 0)
VAR_1->channels = 1; break; case AVMEDIA_TYPE_VIDEO:
if (VAR_1->bit_rate == 0)
VAR_1->bit_rate = 64000; if (VAR_1->time_base.num == 0){ VAR_1->time_base.den = 5; VAR_1->time_base.num = 1; } if (VAR_1->width == 0 || VAR_1->height == 0) { VAR_1->width = 160; VAR_1->height = 128; } if (VAR_1->bit_rate_tolerance == 0)
VAR_1->bit_rate_tolerance = FFMAX(VAR_1->bit_rate / 4,
(int64_t)VAR_1->bit_rate*VAR_1->time_base.num/VAR_1->time_base.den); if (VAR_1->qmin == 0)
VAR_1->qmin = 3; if (VAR_1->qmax == 0)
VAR_1->qmax = 31; if (VAR_1->max_qdiff == 0)
VAR_1->max_qdiff = 3; VAR_1->qcompress = 0.5; VAR_1->qblur = 0.5; if (!VAR_1->nsse_weight)
VAR_1->nsse_weight = 8; VAR_1->frame_skip_cmp = FF_CMP_DCTMAX; if (!VAR_1->me_method)
VAR_1->me_method = ME_EPZS; VAR_1->rc_buffer_aggressivity = 1.0; if (!VAR_1->rc_eq)
VAR_1->rc_eq = av_strdup("tex^qComp"); if (!VAR_1->i_quant_factor)
VAR_1->i_quant_factor = -0.8; if (!VAR_1->b_quant_factor)
VAR_1->b_quant_factor = 1.25; if (!VAR_1->b_quant_offset)
VAR_1->b_quant_offset = 1.25; if (!VAR_1->rc_max_rate)
VAR_1->rc_max_rate = VAR_1->bit_rate * 2; if (VAR_1->rc_max_rate && !VAR_1->rc_buffer_size) { VAR_1->rc_buffer_size = VAR_1->rc_max_rate; } break; default:
abort(); } st = av_mallocz(sizeof(AVStream)); if (!st)
return; st->codec = avcodec_alloc_context3(NULL); VAR_0->streams[VAR_0->nb_streams++] = st; memcpy(st->codec, VAR_1, sizeof(AVCodecContext)); }