# HG changeset patch # User nicodvb # Date 1194003783 0 # Node ID c1660ecae8c40e650a1d3a5e0dc24863f6e491e8 # Parent bddde415c844041db98a72bf73b4257d8311cc01 100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs diff -r bddde415c844 -r c1660ecae8c4 libmpdemux/muxer_mpeg.c --- a/libmpdemux/muxer_mpeg.c Thu Nov 01 23:33:51 2007 +0000 +++ b/libmpdemux/muxer_mpeg.c Fri Nov 02 11:43:03 2007 +0000 @@ -726,7 +726,7 @@ if(mux_type == MUX_MPEG2) - { + { if(h->buffer_size > 0) { buff[len] = 0x1e; //std flag @@ -2227,9 +2227,7 @@ spriv->max_buffer_size = 16*1024; } else if(stream->wf->wFormatTag == AUDIO_AAC1 || stream->wf->wFormatTag == AUDIO_AAC2) - { priv->use_psm = 1; - } else if(stream->wf->wFormatTag == AUDIO_MP2 || stream->wf->wFormatTag == AUDIO_MP3) spriv->is_ready = 0; } @@ -2239,14 +2237,14 @@ spriv->max_buffer_size = conf_vbuf_size*1024; else { - if(priv->is_dvd) - spriv->max_buffer_size = 232*1024; - else if(priv->is_xsvcd) - spriv->max_buffer_size = 230*1024; - else if(priv->is_xvcd) - spriv->max_buffer_size = 46*1024; - else - spriv->max_buffer_size = 232*1024; //no profile => unconstrained :) FIXME!!! + if(priv->is_dvd) + spriv->max_buffer_size = 232*1024; + else if(priv->is_xsvcd) + spriv->max_buffer_size = 230*1024; + else if(priv->is_xvcd) + spriv->max_buffer_size = 46*1024; + else + spriv->max_buffer_size = 232*1024; //no profile => unconstrained :) FIXME!!! } if(is_mpeg4(stream->bih->biCompression)) @@ -2257,110 +2255,115 @@ } -static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts_arg, double pts_arg){ - size_t sz = 0; - uint64_t tmp; - muxer_t *muxer = s->muxer; - muxer_priv_t *priv = (muxer_priv_t *)muxer->priv; - muxer_headers_t *spriv = (muxer_headers_t*) s->priv; - float fps; - uint32_t stream_format, nf; +static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts_arg, double pts_arg) +{ + size_t sz = 0; + uint64_t tmp; + muxer_t *muxer = s->muxer; + muxer_priv_t *priv = (muxer_priv_t *)muxer->priv; + muxer_headers_t *spriv = (muxer_headers_t*) s->priv; + float fps; + uint32_t stream_format, nf; + + if(s->buffer == NULL || len == -1) + return; + + if (s->type == MUXER_TYPE_VIDEO) + { // try to recognize frame type... + fps = (float) s->h.dwRate/ (float) s->h.dwScale; + spriv->type = 1; + stream_format = s->bih->biCompression; + if(! spriv->vframes) + { + spriv->last_dts = spriv->last_pts - (uint64_t)(27000000.0f/fps); + mp_msg(MSGT_MUXER, MSGL_INFO,"INITV: %.3lf, %.3lf, fps: %.3f\r\n", (double) spriv->last_pts/27000000.0f, (double) spriv->last_dts/27000000.0f, fps); + } - if(s->buffer == NULL) - return; - if(len == -1) - return; - - if (s->type == MUXER_TYPE_VIDEO) { // try to recognize frame type... - fps = (float) s->h.dwRate/ (float) s->h.dwScale; - spriv->type = 1; - stream_format = s->bih->biCompression; - if(! spriv->vframes) - { - spriv->last_dts = spriv->last_pts - (uint64_t)(27000000.0f/fps); - mp_msg(MSGT_MUXER, MSGL_INFO,"INITV: %.3lf, %.3lf, fps: %.3f\r\n", (double) spriv->last_pts/27000000.0f, (double) spriv->last_dts/27000000.0f, fps); + if(is_mpeg1(stream_format) || is_mpeg2(stream_format)) + { + spriv->is_mpeg12 = 1; + spriv->is_ready = 1; + if(len) + sz = parse_mpeg12_video(s, priv, spriv, fps, len); + else + { + tmp = (uint64_t) (27000000.0f / fps); + spriv->last_pts += tmp; + spriv->last_dts += tmp; + } + } + else if(is_mpeg4(stream_format)) + { + spriv->is_mpeg12 = 0; + spriv->telecine = 0; + if(spriv->size == 0) + priv->use_psm = 1; + if(len) + sz = parse_mpeg4_video(s, priv, spriv, fps, len); + else + { + tmp = (uint64_t) (27000000.0f / fps); + spriv->last_pts += tmp; + spriv->last_dts += tmp; + } + } + + mp_msg(MSGT_MUXER, MSGL_DBG2,"mpegfile_write_chunk, Video codec=%x, len=%u, mpeg12 returned %u\n", stream_format, (uint32_t) len, (uint32_t) sz); + } + else + { // MUXER_TYPE_AUDIO + double fake_timer; + spriv->type = 0; + stream_format = s->wf->wFormatTag; + + if(s->b_buffer_size - s->b_buffer_len < len) + { + if(s->b_buffer_len > SIZE_MAX - len) + { + mp_msg(MSGT_MUXER, MSGL_FATAL, "\nFATAL! couldn't realloc, integer overflow\n"); + return; + } + s->b_buffer = realloc(s->b_buffer, len + s->b_buffer_len); + if(s->b_buffer == NULL) + { + mp_msg(MSGT_MUXER, MSGL_FATAL, "\nFATAL! couldn't realloc %d bytes\n", len + s->b_buffer_len); + return; + } + + s->b_buffer_size = len + s->b_buffer_len; + mp_msg(MSGT_MUXER, MSGL_DBG2, "REALLOC(%d) bytes to AUDIO backbuffer\n", s->b_buffer_size); + } + memcpy(&(s->b_buffer[s->b_buffer_ptr + s->b_buffer_len]), s->buffer, len); + s->b_buffer_len += len; + + if(!spriv->is_ready) + { + if(s->b_buffer_len >= 32*1024) + { + spriv->mpa_layer = analyze_mpa(s); + spriv->is_ready = 1; + } + } + else + { + parse_audio(s, 0, &nf, &fake_timer, priv->init_adelay, priv->drop); + spriv->vframes += nf; + if(! spriv->vframes) + mp_msg(MSGT_MUXER, MSGL_INFO, "AINIT: %.3lf\r\n", (double) spriv->last_pts/27000000.0f); + } } - if(is_mpeg1(stream_format) || is_mpeg2(stream_format)) - { - spriv->is_mpeg12 = 1; - spriv->is_ready = 1; - if(len) - sz = parse_mpeg12_video(s, priv, spriv, fps, len); - else { - tmp = (uint64_t) (27000000.0f / fps); - spriv->last_pts += tmp; - spriv->last_dts += tmp; - } - } - else if(is_mpeg4(stream_format)) - { - spriv->is_mpeg12 = 0; - spriv->telecine = 0; - if(spriv->size == 0) - priv->use_psm = 1; - if(len) - sz = parse_mpeg4_video(s, priv, spriv, fps, len); - else { - tmp = (uint64_t) (27000000.0f / fps); - spriv->last_pts += tmp; - spriv->last_dts += tmp; - } - } - mp_msg(MSGT_MUXER, MSGL_DBG2,"mpegfile_write_chunk, Video codec=%x, len=%u, mpeg12 returned %u\n", stream_format, (uint32_t) len, (uint32_t) sz); - } else { // MUXER_TYPE_AUDIO - double fake_timer; - spriv->type = 0; - stream_format = s->wf->wFormatTag; - - if(s->b_buffer_size - s->b_buffer_len < len) + if(spriv->psm_fixed == 0) { - if(s->b_buffer_len > SIZE_MAX - len) - { - mp_msg(MSGT_MUXER, MSGL_FATAL, "\nFATAL! couldn't realloc, integer overflow\n"); - return; - } - s->b_buffer = realloc(s->b_buffer, len + s->b_buffer_len); - if(s->b_buffer == NULL) - { - mp_msg(MSGT_MUXER, MSGL_FATAL, "\nFATAL! couldn't realloc %d bytes\n", len + s->b_buffer_len); - return; - } - - s->b_buffer_size = len + s->b_buffer_len; - mp_msg(MSGT_MUXER, MSGL_DBG2, "REALLOC(%d) bytes to AUDIO backbuffer\n", s->b_buffer_size); + add_to_psm(priv, spriv->id, stream_format); + spriv->psm_fixed = 1; + priv->psm_streams_cnt++; + if((priv->psm_streams_cnt == muxer->num_videos + muxer->num_audios) && priv->use_psm) + write_psm_block(muxer, muxer->stream); } - memcpy(&(s->b_buffer[s->b_buffer_ptr + s->b_buffer_len]), s->buffer, len); - s->b_buffer_len += len; - - if(!spriv->is_ready) - { - if(s->b_buffer_len >= 32*1024) - { - spriv->mpa_layer = analyze_mpa(s); - spriv->is_ready = 1; - } - } - else - { - parse_audio(s, 0, &nf, &fake_timer, priv->init_adelay, priv->drop); - spriv->vframes += nf; - if(! spriv->vframes) - mp_msg(MSGT_MUXER, MSGL_INFO, "AINIT: %.3lf\r\n", (double) spriv->last_pts/27000000.0f); - } - } - - if(spriv->psm_fixed == 0) { - add_to_psm(priv, spriv->id, stream_format); - spriv->psm_fixed = 1; - priv->psm_streams_cnt++; - if((priv->psm_streams_cnt == muxer->num_videos + muxer->num_audios) && priv->use_psm) - write_psm_block(muxer, muxer->stream); - } - - flush_buffers(muxer, 0); + flush_buffers(muxer, 0); } @@ -2476,236 +2479,238 @@ } } -int muxer_init_muxer_mpeg(muxer_t *muxer){ - muxer_priv_t *priv; - priv = (muxer_priv_t *) calloc(1, sizeof(muxer_priv_t)); - if(priv == NULL) - return 0; - priv->update_system_header = 1; - - //calloc() already zero-ed all flags, so we assign only the ones we need - - if(conf_mux != NULL) { - if(! strcasecmp(conf_mux, "mpeg1")) - { - priv->mux = MUX_MPEG1; - priv->packet_size = 2048; - priv->is_genmpeg1 = 1; - priv->muxrate = 1800 * 125; //Constrained parameters - } - else if(! strcasecmp(conf_mux, "dvd")) - { - priv->mux = MUX_MPEG2; - priv->is_dvd = 1; - priv->packet_size = 2048; - priv->muxrate = 10080 * 125; - } - else if(! strcasecmp(conf_mux, "xsvcd")) - { - priv->mux = MUX_MPEG2; - priv->is_xsvcd = 1; - priv->packet_size = 2324; - priv->muxrate = 150*2324; - priv->ts_allframes = 1; - } - else if(! strcasecmp(conf_mux, "xvcd")) - { - priv->mux = MUX_MPEG1; - priv->is_xvcd = 1; - priv->packet_size = 2324; - priv->muxrate = 75*2352; - priv->ts_allframes = 1; - } - else if(! strcasecmp(conf_mux, "pes1")) - { - priv->mux = MUX_MPEG1; - priv->rawpes = 1; - priv->packet_size = 2048; - priv->muxrate = 10080 * 125; - priv->ts_allframes = 1; - } - else if(! strcasecmp(conf_mux, "pes2")) - { - priv->mux = MUX_MPEG2; - priv->rawpes = 1; - priv->packet_size = 2048; - priv->muxrate = 10080 * 125; - priv->ts_allframes = 1; - } - else - { - if(strcasecmp(conf_mux, "mpeg2")) - mp_msg(MSGT_MUXER, MSGL_ERR, "Unknown format %s, default to mpeg2\n", conf_mux); - priv->mux = MUX_MPEG2; - priv->is_genmpeg2 = 1; - priv->packet_size = 2048; - priv->muxrate = 1800 * 125; //Constrained parameters - } - } - - if(conf_ts_allframes) - priv->ts_allframes = 1; - if(conf_muxrate > 0) - priv->muxrate = conf_muxrate * 125; // * 1000 / 8 - if(conf_packet_size) - priv->packet_size = conf_packet_size; - priv->delta_scr = (uint64_t) (90000.0f*300.0f*(double)priv->packet_size/(double)priv->muxrate); - mp_msg(MSGT_MUXER, MSGL_INFO, "PACKET SIZE: %u bytes, deltascr: %"PRIu64"\n", priv->packet_size, priv->delta_scr); - setup_sys_params(priv); - - if(conf_vaspect > 0) - { - int asp = (int) (conf_vaspect * 1000.0f); - if(asp >= 1332 && asp <= 1334) - priv->vaspect = ASPECT_4_3; - else if(asp >= 1776 && asp <= 1778) - priv->vaspect = ASPECT_16_9; - else if(asp >= 2209 && asp <= 2211) - priv->vaspect = ASPECT_2_21_1; - else if(asp == 1000) - priv->vaspect = ASPECT_1_1; - else - mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR: unrecognized aspect %.3f\n", conf_vaspect); - } - - priv->vframerate = 0; // no change - if(conf_telecine && conf_vframerate > 0) - { - mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR: options 'telecine' and 'vframerate' are mutually exclusive, vframerate disabled\n"); - conf_vframerate = 0; - } - - if(conf_telecine == TELECINE_FILM2PAL) - { - if(conf_telecine_src==0.0f) conf_telecine_src = 24000.0/1001.0; - conf_telecine_dest = 25; - conf_telecine = TELECINE_DGPULLDOWN; - } - else if(conf_telecine == PULLDOWN32) - { - if(conf_telecine_src==0.0f) conf_telecine_src = 24000.0/1001.0; - conf_telecine_dest = 30000.0/1001.0; - conf_telecine = TELECINE_DGPULLDOWN; - } - - if(conf_telecine_src>0 && conf_telecine_dest>0 && conf_telecine_src < conf_telecine_dest) - { - int sfps, tfps; +int muxer_init_muxer_mpeg(muxer_t *muxer) +{ + muxer_priv_t *priv; + priv = (muxer_priv_t *) calloc(1, sizeof(muxer_priv_t)); + if(priv == NULL) + return 0; + priv->update_system_header = 1; + + //calloc() already zero-ed all flags, so we assign only the ones we need - sfps = (int) (conf_telecine_src * 1001 + 0.5); - tfps = (int) (conf_telecine_dest * 1001 + 0.5); - if(sfps % 2 || tfps % 2) + if(conf_mux != NULL) { - sfps *= 2; - tfps *= 2; + if(! strcasecmp(conf_mux, "mpeg1")) + { + priv->mux = MUX_MPEG1; + priv->packet_size = 2048; + priv->is_genmpeg1 = 1; + priv->muxrate = 1800 * 125; //Constrained parameters + } + else if(! strcasecmp(conf_mux, "dvd")) + { + priv->mux = MUX_MPEG2; + priv->is_dvd = 1; + priv->packet_size = 2048; + priv->muxrate = 10080 * 125; + } + else if(! strcasecmp(conf_mux, "xsvcd")) + { + priv->mux = MUX_MPEG2; + priv->is_xsvcd = 1; + priv->packet_size = 2324; + priv->muxrate = 150*2324; + priv->ts_allframes = 1; + } + else if(! strcasecmp(conf_mux, "xvcd")) + { + priv->mux = MUX_MPEG1; + priv->is_xvcd = 1; + priv->packet_size = 2324; + priv->muxrate = 75*2352; + priv->ts_allframes = 1; + } + else if(! strcasecmp(conf_mux, "pes1")) + { + priv->mux = MUX_MPEG1; + priv->rawpes = 1; + priv->packet_size = 2048; + priv->muxrate = 10080 * 125; + priv->ts_allframes = 1; + } + else if(! strcasecmp(conf_mux, "pes2")) + { + priv->mux = MUX_MPEG2; + priv->rawpes = 1; + priv->packet_size = 2048; + priv->muxrate = 10080 * 125; + priv->ts_allframes = 1; + } + else + { + if(strcasecmp(conf_mux, "mpeg2")) + mp_msg(MSGT_MUXER, MSGL_ERR, "Unknown format %s, default to mpeg2\n", conf_mux); + priv->mux = MUX_MPEG2; + priv->is_genmpeg2 = 1; + priv->packet_size = 2048; + priv->muxrate = 1800 * 125; //Constrained parameters + } + } + + if(conf_ts_allframes) + priv->ts_allframes = 1; + if(conf_muxrate > 0) + priv->muxrate = conf_muxrate * 125; // * 1000 / 8 + if(conf_packet_size) + priv->packet_size = conf_packet_size; + priv->delta_scr = (uint64_t) (90000.0f*300.0f*(double)priv->packet_size/(double)priv->muxrate); + mp_msg(MSGT_MUXER, MSGL_INFO, "PACKET SIZE: %u bytes, deltascr: %"PRIu64"\n", priv->packet_size, priv->delta_scr); + setup_sys_params(priv); + + if(conf_vaspect > 0) + { + int asp = (int) (conf_vaspect * 1000.0f); + if(asp >= 1332 && asp <= 1334) + priv->vaspect = ASPECT_4_3; + else if(asp >= 1776 && asp <= 1778) + priv->vaspect = ASPECT_16_9; + else if(asp >= 2209 && asp <= 2211) + priv->vaspect = ASPECT_2_21_1; + else if(asp == 1000) + priv->vaspect = ASPECT_1_1; + else + mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR: unrecognized aspect %.3f\n", conf_vaspect); + } + + priv->vframerate = 0; // no change + if(conf_telecine && conf_vframerate > 0) + { + mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR: options 'telecine' and 'vframerate' are mutually exclusive, vframerate disabled\n"); + conf_vframerate = 0; + } + + if(conf_telecine == TELECINE_FILM2PAL) + { + if(conf_telecine_src==0.0f) conf_telecine_src = 24000.0/1001.0; + conf_telecine_dest = 25; + conf_telecine = TELECINE_DGPULLDOWN; + } + else if(conf_telecine == PULLDOWN32) + { + if(conf_telecine_src==0.0f) conf_telecine_src = 24000.0/1001.0; + conf_telecine_dest = 30000.0/1001.0; + conf_telecine = TELECINE_DGPULLDOWN; } - if(((tfps - sfps)>>1) > sfps) - { - mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR! Framerate increment must be <= 1.5, telecining disabled\n"); - conf_telecine = 0; - } - else - { - generate_flags(sfps, tfps); - conf_telecine = TELECINE_DGPULLDOWN; - conf_vframerate = conf_telecine_dest; - } - } - - if(conf_vframerate) - { - int fps; - - fps = (int) (conf_vframerate * 1001 + 0.5); - switch(fps) + if(conf_telecine_src>0 && conf_telecine_dest>0 && conf_telecine_src < conf_telecine_dest) { - case 24000: - priv->vframerate = FRAMERATE_23976; - break; - case 24024: - priv->vframerate = FRAMERATE_24; - break; - case 25025: - priv->vframerate = FRAMERATE_25; - break; - case 30000: - priv->vframerate = FRAMERATE_2997; - break; - case 30030: - priv->vframerate = FRAMERATE_30; - break; - case 50050: - priv->vframerate = FRAMERATE_50; - break; - case 60000: - priv->vframerate = FRAMERATE_5994; - break; - case 60060: - priv->vframerate = FRAMERATE_60; - break; - default: + int sfps, tfps; + + sfps = (int) (conf_telecine_src * 1001 + 0.5); + tfps = (int) (conf_telecine_dest * 1001 + 0.5); + if(sfps % 2 || tfps % 2) { - mp_msg(MSGT_MUXER, MSGL_ERR, "WRONG FPS: %d/1000, ignoring\n", fps); - if(conf_telecine) - mp_msg(MSGT_MUXER, MSGL_ERR, "DISABLED TELECINING\n"); + sfps *= 2; + tfps *= 2; + } + + if(((tfps - sfps)>>1) > sfps) + { + mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR! Framerate increment must be <= 1.5, telecining disabled\n"); conf_telecine = 0; } + else + { + generate_flags(sfps, tfps); + conf_telecine = TELECINE_DGPULLDOWN; + conf_vframerate = conf_telecine_dest; + } } - } - - priv->vwidth = (uint16_t) conf_vwidth; - priv->vheight = (uint16_t) conf_vheight; - priv->panscan_width = (uint16_t) conf_panscan_width; - priv->panscan_height = (uint16_t) conf_panscan_height; - priv->vbitrate = ((conf_vbitrate) * 10) >> 2; //*1000 / 400 - - if(priv->vaspect || priv->vframerate || priv->vwidth || priv->vheight || priv->vbitrate || priv->panscan_width || priv->panscan_height) - { - priv->patch_seq = priv->vaspect || priv->vframerate || priv->vwidth || priv->vheight || priv->vbitrate; - priv->patch_sde = priv->panscan_width || priv->panscan_height; - mp_msg(MSGT_MUXER, MSGL_INFO, "MPEG MUXER, patching"); - if(priv->vwidth || priv->vheight) - mp_msg(MSGT_MUXER, MSGL_INFO, " resolution to %dx%d", priv->vwidth, priv->vheight); - if(priv->panscan_width || priv->panscan_height) - mp_msg(MSGT_MUXER, MSGL_INFO, " panscan to to %dx%d", priv->panscan_width, priv->panscan_height); - if(priv->vframerate) - mp_msg(MSGT_MUXER, MSGL_INFO, " framerate to %s fps", framerates[priv->vframerate]); - if(priv->vaspect) - mp_msg(MSGT_MUXER, MSGL_INFO, " aspect ratio to %s", aspect_ratios[priv->vaspect]); - if(priv->vbitrate) - mp_msg(MSGT_MUXER, MSGL_INFO, " bitrate to %u", conf_vbitrate); - mp_msg(MSGT_MUXER, MSGL_INFO, "\n"); - } - - priv->has_video = priv->has_audio = 0; - - muxer->sysrate = priv->muxrate; // initial muxrate = constrained stream parameter - priv->scr = muxer->file_end = 0; - - if(conf_init_vdelay && conf_drop) - { - mp_msg(MSGT_MUXER, MSGL_ERR, "\nmuxer_mpg, :drop and :vdelay used together are not supported, exiting\n"); - return 0; - } - if(conf_init_adelay) - priv->init_adelay = - (double) conf_init_adelay / (double) 1000.0; - - priv->drop = conf_drop; - - priv->buff = (uint8_t *) malloc(priv->packet_size); - if((priv->buff == NULL)) - { - mp_msg(MSGT_MUXER, MSGL_ERR, "\nCouldn't allocate %d bytes, exit\n", priv->packet_size); - return 0; - } - - muxer->priv = (void *) priv; - muxer->cont_new_stream = &mpegfile_new_stream; - muxer->cont_write_chunk = &mpegfile_write_chunk; - muxer->cont_write_header = &mpegfile_write_header; - muxer->cont_write_index = &mpegfile_write_index; - muxer->fix_stream_parameters = &fix_parameters; - return 1; + + if(conf_vframerate) + { + int fps; + + fps = (int) (conf_vframerate * 1001 + 0.5); + switch(fps) + { + case 24000: + priv->vframerate = FRAMERATE_23976; + break; + case 24024: + priv->vframerate = FRAMERATE_24; + break; + case 25025: + priv->vframerate = FRAMERATE_25; + break; + case 30000: + priv->vframerate = FRAMERATE_2997; + break; + case 30030: + priv->vframerate = FRAMERATE_30; + break; + case 50050: + priv->vframerate = FRAMERATE_50; + break; + case 60000: + priv->vframerate = FRAMERATE_5994; + break; + case 60060: + priv->vframerate = FRAMERATE_60; + break; + default: + { + mp_msg(MSGT_MUXER, MSGL_ERR, "WRONG FPS: %d/1000, ignoring\n", fps); + if(conf_telecine) + mp_msg(MSGT_MUXER, MSGL_ERR, "DISABLED TELECINING\n"); + conf_telecine = 0; + } + } + } + + priv->vwidth = (uint16_t) conf_vwidth; + priv->vheight = (uint16_t) conf_vheight; + priv->panscan_width = (uint16_t) conf_panscan_width; + priv->panscan_height = (uint16_t) conf_panscan_height; + priv->vbitrate = ((conf_vbitrate) * 10) >> 2; //*1000 / 400 + + if(priv->vaspect || priv->vframerate || priv->vwidth || priv->vheight || priv->vbitrate || priv->panscan_width || priv->panscan_height) + { + priv->patch_seq = priv->vaspect || priv->vframerate || priv->vwidth || priv->vheight || priv->vbitrate; + priv->patch_sde = priv->panscan_width || priv->panscan_height; + mp_msg(MSGT_MUXER, MSGL_INFO, "MPEG MUXER, patching"); + if(priv->vwidth || priv->vheight) + mp_msg(MSGT_MUXER, MSGL_INFO, " resolution to %dx%d", priv->vwidth, priv->vheight); + if(priv->panscan_width || priv->panscan_height) + mp_msg(MSGT_MUXER, MSGL_INFO, " panscan to to %dx%d", priv->panscan_width, priv->panscan_height); + if(priv->vframerate) + mp_msg(MSGT_MUXER, MSGL_INFO, " framerate to %s fps", framerates[priv->vframerate]); + if(priv->vaspect) + mp_msg(MSGT_MUXER, MSGL_INFO, " aspect ratio to %s", aspect_ratios[priv->vaspect]); + if(priv->vbitrate) + mp_msg(MSGT_MUXER, MSGL_INFO, " bitrate to %u", conf_vbitrate); + mp_msg(MSGT_MUXER, MSGL_INFO, "\n"); + } + + priv->has_video = priv->has_audio = 0; + + muxer->sysrate = priv->muxrate; // initial muxrate = constrained stream parameter + priv->scr = muxer->file_end = 0; + + if(conf_init_vdelay && conf_drop) + { + mp_msg(MSGT_MUXER, MSGL_ERR, "\nmuxer_mpg, :drop and :vdelay used together are not supported, exiting\n"); + return 0; + } + if(conf_init_adelay) + priv->init_adelay = - (double) conf_init_adelay / (double) 1000.0; + + priv->drop = conf_drop; + + priv->buff = (uint8_t *) malloc(priv->packet_size); + if((priv->buff == NULL)) + { + mp_msg(MSGT_MUXER, MSGL_ERR, "\nCouldn't allocate %d bytes, exit\n", priv->packet_size); + return 0; + } + + muxer->priv = (void *) priv; + muxer->cont_new_stream = &mpegfile_new_stream; + muxer->cont_write_chunk = &mpegfile_write_chunk; + muxer->cont_write_header = &mpegfile_write_header; + muxer->cont_write_index = &mpegfile_write_index; + muxer->fix_stream_parameters = &fix_parameters; + return 1; }