diff options
author | 2009-07-07 02:26:13 +0300 | |
---|---|---|
committer | 2009-07-07 02:34:35 +0300 | |
commit | 0eb321bf2c1cc0e048faff26a01f86cdd3ec254f (patch) | |
tree | 71cb9bd9ed121156d3382066c0722c73189afe04 /libmpdemux/muxer_mpeg.c | |
parent | 6d908205fbadbdf7ccdc6c5e0eb918f0b43f16e0 (diff) |
Remove trailing whitespace from most files
Diffstat (limited to 'libmpdemux/muxer_mpeg.c')
-rw-r--r-- | libmpdemux/muxer_mpeg.c | 401 |
1 files changed, 200 insertions, 201 deletions
diff --git a/libmpdemux/muxer_mpeg.c b/libmpdemux/muxer_mpeg.c index 1a3c8a2270..321b6546b0 100644 --- a/libmpdemux/muxer_mpeg.c +++ b/libmpdemux/muxer_mpeg.c @@ -72,7 +72,7 @@ #define FRAMERATE_5994 7 #define FRAMERATE_60 8 -static char ftypes[] = {'?', 'I', 'P', 'B'}; +static char ftypes[] = {'?', 'I', 'P', 'B'}; #define FTYPE(x) (ftypes[(x)]) static const char *framerates[] = { @@ -86,7 +86,7 @@ static const char *aspect_ratios[] = { static char *conf_mux = "mpeg2"; static uint16_t conf_packet_size = 0; //dvd static uint32_t conf_muxrate = 0; //kb/s -static float conf_vaspect = 0; +static float conf_vaspect = 0; static float conf_vframerate = 0; static uint32_t conf_vwidth = 0, conf_vheight = 0, conf_panscan_width = 0, conf_panscan_height = 0; static uint32_t conf_vbitrate = 0; @@ -161,7 +161,7 @@ typedef struct { uint32_t headers_cnt; double init_adelay; int drop; - + //video patching parameters uint8_t vaspect, vframerate; uint16_t vwidth, vheight, panscan_width, panscan_height; @@ -236,7 +236,7 @@ int mp_a52_framesize(uint8_t *buf, int *srate); static void fix_audio_sys_header(muxer_priv_t *priv, uint8_t id, uint8_t newid, uint32_t size) { uint8_t i; - + for(i = 0; i < priv->sys_info.cnt; i++) { if(priv->sys_info.streams[i].id == id) @@ -289,7 +289,7 @@ static inline int is_mpeg4(uint32_t x) static uint32_t CalcCRC32(uint8_t *buff, uint32_t size) { uint32_t i, j, CRCTab[256], crc; - + for(i = 0;i < 256; i++) { for(crc = i, j = 0; j < 8; j++) @@ -297,11 +297,11 @@ static uint32_t CalcCRC32(uint8_t *buff, uint32_t size) CRCTab[i] = crc; } - + crc = 0xffffffff; for(i = 0; i < size; i++) crc = (crc << 8) ^ CRCTab[((crc >> 24) ^ buff[i]) & 0xff]; - + return crc; } @@ -309,11 +309,11 @@ static uint32_t CalcCRC32(uint8_t *buff, uint32_t size) static void add_to_psm(muxer_priv_t *priv, uint8_t id, uint32_t format) { uint8_t i; - + i = priv->psm_info.cnt; priv->psm_info.streams[i].id = id; priv->psm_info.streams[i].format = format; - + if(is_mpeg1(format)) priv->psm_info.streams[i].type = 0x01; else if(is_mpeg2(format)) @@ -326,10 +326,10 @@ static void add_to_psm(muxer_priv_t *priv, uint8_t id, uint32_t format) priv->psm_info.streams[i].type = 0x0f; else priv->psm_info.streams[i].type = 0x81; - + if(format == AUDIO_A52) memcpy((char*) &(priv->psm_info.streams[i].format), "AC-3", 4); - + priv->psm_info.cnt++; } @@ -338,11 +338,11 @@ static mpeg_frame_t *init_frames(uint16_t num, size_t size) { mpeg_frame_t *tmp; uint16_t i; - + tmp = (mpeg_frame_t *) calloc(num, sizeof(mpeg_frame_t)); if(tmp == NULL) return NULL; - + for(i=0; i < num; i++) { tmp[i].buffer = (uint8_t *) calloc(1, size); @@ -353,7 +353,7 @@ static mpeg_frame_t *init_frames(uint16_t num, size_t size) tmp[i].alloc_size = size; tmp[i].pts = 0; } - + return tmp; } @@ -517,10 +517,10 @@ static void write_mpeg_ts(unsigned char *b, uint64_t ts, uint8_t mod) { } -static void write_mpeg_rate(int type, unsigned char *b, unsigned int rate) +static void write_mpeg_rate(int type, unsigned char *b, unsigned int rate) { rate = ((rate*8)+399) / 400; - + if(type == MUX_MPEG1) { b[0] = ((rate >> 15) & 0x7f) | 0x80; @@ -531,12 +531,12 @@ static void write_mpeg_rate(int type, unsigned char *b, unsigned int rate) { b[0] = (rate >> 14); b[1] = (rate >> 6) & 0xff; - b[2] = ((rate & 0x3f) << 2) | 0x03; + b[2] = ((rate & 0x3f) << 2) | 0x03; } } -static void write_mpeg_std(unsigned char *b, unsigned int size, unsigned int type, uint8_t mod) +static void write_mpeg_std(unsigned char *b, unsigned int size, unsigned int type, uint8_t mod) { //type = 0:mpeg audio/128, 1:video and pes private streams (including ac3/dts/lpcm)/1024 if(type == 0) //audio @@ -551,7 +551,7 @@ static void write_mpeg_std(unsigned char *b, unsigned int size, unsigned int typ b[1] = size & 0xff; } -static void write_mpeg2_scr(unsigned char *b, uint64_t ts) +static void write_mpeg2_scr(unsigned char *b, uint64_t ts) { uint16_t t1, t2, t3, scr_ext; scr_ext = ts % 300ULL; @@ -560,7 +560,7 @@ static void write_mpeg2_scr(unsigned char *b, uint64_t ts) t1 = (ts >> 30) & 0x7; t2 = (ts >> 15) & 0x7fff; t3 = ts & 0x7fff; - + b[0] = (t1 << 3 ) | 0x44 | ((t2 >> 13) & 0x3); b[1] = (t2 >> 5); b[2] = (t2 & 0x1f) << 3 | 0x4 | ((t3 >> 13) & 0x3); @@ -574,7 +574,7 @@ static int write_mpeg_pack_header(muxer_t *muxer, char *buff) { int len; muxer_priv_t *priv; - + priv = (muxer_priv_t *) muxer->priv; *(uint32_t *)buff = be2me_32(PACK_HEADER_START_CODE); if(priv->mux==MUX_MPEG1) @@ -587,7 +587,7 @@ static int write_mpeg_pack_header(muxer_t *muxer, char *buff) { write_mpeg2_scr(&buff[4], priv->scr); // 0010 and SCR write_mpeg_rate(priv->mux, &buff[10], muxer->sysrate); - buff[13] = 0xf8; //5 bits reserved + 3 set to 0 to indicate 0 stuffing bytes + buff[13] = 0xf8; //5 bits reserved + 3 set to 0 to indicate 0 stuffing bytes len = 14; } @@ -601,7 +601,7 @@ static int write_mpeg_system_header(muxer_t *muxer, char *buff) uint8_t i; muxer_priv_t *priv; priv = (muxer_priv_t *) muxer->priv; - + len = 0; *(uint32_t *)(&buff[len]) = be2me_32(SYSTEM_HEADER_START_CODE); len += 4; @@ -609,26 +609,26 @@ static int write_mpeg_system_header(muxer_t *muxer, char *buff) len += 2; write_mpeg_rate(MUX_MPEG1, &buff[len], muxer->sysrate); len += 3; - + buff[len++] = 0x4 | (priv->is_xvcd ? 1 : 0); //1 audio stream bound, no fixed, CSPS only for xvcd //stolen from libavformat if(priv->is_xvcd || priv->is_dvd) buff[len++] = 0xe1; //system_audio_lock, system_video_lock, marker, 1 video stream bound else buff[len++] = 0x21; //marker, 1 video stream bound - + buff[len++] = ((priv->mux == MUX_MPEG1) ? 0xff : 0x7f); //in mpeg2 there's the packet rate restriction - + for(i = 0; i < priv->sys_info.cnt; i++) { buff[len++] = priv->sys_info.streams[i].id; - write_mpeg_std(&buff[len], priv->sys_info.streams[i].bufsize, priv->sys_info.streams[i].type, + write_mpeg_std(&buff[len], priv->sys_info.streams[i].bufsize, priv->sys_info.streams[i].type, (priv->sys_info.streams[i].type == 1 ? 0xe0: 0xc0)); len += 2; } - + *(uint16_t *)(&buff[4]) = be2me_16(len - 6); // length field fixed - + return len; } @@ -639,7 +639,7 @@ static int write_mpeg_psm(muxer_t *muxer, char *buff) uint16_t dlen; muxer_priv_t *priv; priv = (muxer_priv_t *) muxer->priv; - + len = 0; *(uint32_t *)(&buff[len]) = be2me_32(PSM_START_CODE); len += 4; @@ -651,13 +651,13 @@ static int write_mpeg_psm(muxer_t *muxer, char *buff) len += 2; *(uint16_t *)(&buff[len]) = 0; //length of the es descriptors len += 2; - + dlen = 0; for(i = 0; i < priv->psm_info.cnt; i++) { if( - (priv->psm_info.streams[i].id == 0xbd) || - (priv->psm_info.streams[i].id >= 0xe0 && priv->psm_info.streams[i].id <= 0xef) || + (priv->psm_info.streams[i].id == 0xbd) || + (priv->psm_info.streams[i].id >= 0xe0 && priv->psm_info.streams[i].id <= 0xef) || (priv->psm_info.streams[i].id >= 0xc0 && priv->psm_info.streams[i].id <= 0xcf) ) { @@ -665,18 +665,18 @@ static int write_mpeg_psm(muxer_t *muxer, char *buff) buff[len++] = priv->psm_info.streams[i].id; buff[len++] = 0; //len of descriptor upper ... buff[len++] = 0; //... lower - + dlen += 4; } } *(uint16_t *)(&buff[10]) = be2me_16(dlen); //length of the es descriptors - + *(uint16_t *)(&buff[4]) = be2me_16(len - 6 + 4); // length field fixed, including size of CRC32 - + *(uint32_t *)(&buff[len]) = be2me_32(CalcCRC32(buff, len)); - + len += 4; //for crc - + return len; } @@ -688,7 +688,7 @@ static int psm_is_late(muxer_priv_t *priv) static int write_mpeg_pes_header(muxer_headers_t *h, uint8_t *pes_id, uint8_t *buff, uint16_t plen, int stuffing_len, int mux_type) { int len; - + len = 0; memcpy(&buff[len], pes_id, 4); len += 4; @@ -703,29 +703,29 @@ static int write_mpeg_pes_header(muxer_headers_t *h, uint8_t *pes_id, uint8_t *b memset(&buff[len], 0xff, stuffing_len); len += stuffing_len; } - + if(h->buffer_size > 0) { - write_mpeg_std(&buff[len], h->buffer_size, h->type, 0x40); // 01 is pes1 format + write_mpeg_std(&buff[len], h->buffer_size, h->type, 0x40); // 01 is pes1 format len += 2; } } else //MPEG2 { - buff[len] = (h->pes_is_aligned ? 0x84 : 0x80); //0x10... + buff[len] = (h->pes_is_aligned ? 0x84 : 0x80); //0x10... len++; buff[len] = ((h->buffer_size > 0) ? 1 : 0) | (h->pts ? (h->dts ? 0xC0 : 0x80) : 0); //pes extension + pts/dts flags len++; buff[len] = (h->pts ? (h->dts ? 10 : 5) : 0) + ((h->buffer_size > 0) ? 3 : 0) + stuffing_len;//pts + std + stuffing len++; } - - + + if(h->pts) { write_mpeg_ts(&buff[len], h->pts, (h->dts ? 0x30 : 0x20)); // 001x and both PTS/DTS len += 5; - + if(h->dts) { write_mpeg_ts(&buff[len], h->dts, 0x10); // 0001 before DTS @@ -741,18 +741,18 @@ static int write_mpeg_pes_header(muxer_headers_t *h, uint8_t *pes_id, uint8_t *b } } - + if(mux_type == MUX_MPEG2) { if(h->buffer_size > 0) { buff[len] = 0x1e; //std flag len++; - + write_mpeg_std(&buff[len], h->buffer_size, h->type, 0x40); len += 2; } - + if(stuffing_len > 0) { memset(&buff[len], 0xff, stuffing_len); @@ -760,7 +760,7 @@ static int write_mpeg_pes_header(muxer_headers_t *h, uint8_t *pes_id, uint8_t *b } } - *((uint16_t*) &buff[4]) = be2me_16(len + plen - 6); //fix pes packet size + *((uint16_t*) &buff[4]) = be2me_16(len + plen - 6); //fix pes packet size return len; } @@ -808,12 +808,12 @@ static unsigned int calc_psm_len(muxer_priv_t *priv) static uint32_t calc_pes_hlen(int format, muxer_headers_t *h, muxer_priv_t *priv) { uint32_t len; - + if(format == MUX_MPEG1) len = 6; else len = 9; - + if(h->pts) { len += 5; @@ -822,7 +822,7 @@ static uint32_t calc_pes_hlen(int format, muxer_headers_t *h, muxer_priv_t *priv } else if(format == MUX_MPEG1) len += 1; - + if(h->buffer_size > 0) { if(format == MUX_MPEG2) @@ -832,11 +832,11 @@ static uint32_t calc_pes_hlen(int format, muxer_headers_t *h, muxer_priv_t *priv } //len = max(h->min_pes_hlen, len); - + return len; } - + static int write_mpeg_pack(muxer_t *muxer, muxer_stream_t *s, stream_t *stream, int isoend) { size_t tot, offset; @@ -854,7 +854,7 @@ static int write_mpeg_pack(muxer_t *muxer, muxer_stream_t *s, stream_t *stream, buff[offset + 0] = buff[offset + 1] = 0; buff[offset + 2] = 1; buff[offset + 3] = 0xb9; - + stream_write_buffer(stream, buff, priv->packet_size); return 1; } @@ -862,12 +862,12 @@ static int write_mpeg_pack(muxer_t *muxer, muxer_stream_t *s, stream_t *stream, { offset = write_mpeg_pack_header(muxer, buff); offset += write_mpeg_system_header(muxer, &buff[offset]); - + //priv->update_system_header = 0; - + if(priv->is_dvd) offset += write_nav_pack(&buff[offset]); - + stuffing_len = priv->packet_size - offset; if(stuffing_len > 0) { @@ -875,12 +875,12 @@ static int write_mpeg_pack(muxer_t *muxer, muxer_stream_t *s, stream_t *stream, write_pes_padding(&buff[offset], stuffing_len); offset += stuffing_len; } - + stream_write_buffer(stream, buff, offset); priv->headers_size += offset; tot = offset; muxer->movi_end += tot; - + return tot; } } @@ -983,7 +983,7 @@ static int find_packet_timestamps(muxer_priv_t *priv, muxer_stream_t *s, unsigne { pes_hlen = calc_pes_hlen(priv->mux, spriv, priv); - if(pes_hlen < spriv->min_pes_hlen) + if(pes_hlen < spriv->min_pes_hlen) pes_hlen = spriv->min_pes_hlen; m = spriv->framebuf[0].size - spriv->framebuf[0].pos; @@ -994,13 +994,13 @@ static int find_packet_timestamps(muxer_priv_t *priv, muxer_stream_t *s, unsigne { if(spriv->framebuf_used < 2) goto fail; - + if(spriv->framebuf[1].pts == spriv->framebuf[1].dts) threshold = 5; else threshold = 10; - //headers+frame 0 < space available including timestamps + //headers+frame 0 < space available including timestamps if(start + pes_hlen + m < priv->packet_size - threshold) i = 1; else @@ -1010,7 +1010,7 @@ static int find_packet_timestamps(muxer_priv_t *priv, muxer_stream_t *s, unsigne if(i > -1) { - dpts = FFMAX(spriv->last_saved_pts, spriv->framebuf[i].pts) - + dpts = FFMAX(spriv->last_saved_pts, spriv->framebuf[i].pts) - FFMIN(spriv->last_saved_pts, spriv->framebuf[i].pts) + spriv->framebuf[0].idur; @@ -1073,7 +1073,7 @@ static int get_packet_stats(muxer_priv_t *priv, muxer_stream_t *s, pack_stats_t len -= hlen; target -= hlen; - + len2 = calc_packet_len(s, target, finalize); if(!len2 || (len2 < target && s->type == MUXER_TYPE_AUDIO && !finalize)) { @@ -1114,9 +1114,9 @@ static int get_packet_stats(muxer_priv_t *priv, muxer_stream_t *s, pack_stats_t } } } - + len += hlen; - + p->len = len; p->stflen = stflen; @@ -1184,7 +1184,7 @@ static int fill_packet(muxer_t *muxer, muxer_stream_t *s, int finalize) spriv->buffer_size = bufsize*1024; } - if(priv->is_dvd && s->type == MUXER_TYPE_VIDEO + if(priv->is_dvd && s->type == MUXER_TYPE_VIDEO && spriv->framebuf[0].type==I_FRAME && spriv->framebuf[0].pos==0) dvd_pack = 1; @@ -1197,8 +1197,8 @@ static int fill_packet(muxer_t *muxer, muxer_stream_t *s, int finalize) spriv->pts = p.pts; if(spriv->pts) spriv->last_saved_pts = p.pts; - - spriv->pack_offset += write_mpeg_pes_header(spriv, (uint8_t *) &s->ckid, &(spriv->pack[spriv->pack_offset]), + + spriv->pack_offset += write_mpeg_pes_header(spriv, (uint8_t *) &s->ckid, &(spriv->pack[spriv->pack_offset]), p.len, p.stflen, priv->mux); if(s->type == MUXER_TYPE_AUDIO && s->wf->wFormatTag == AUDIO_A52) @@ -1231,7 +1231,7 @@ static int fill_packet(muxer_t *muxer, muxer_stream_t *s, int finalize) { if(!frm->pos) { - //since iframes must always be aligned at block boundaries exit when we find the + //since iframes must always be aligned at block boundaries exit when we find the //beginning of one in the middle of the flush if(len > 0 && s->type == MUXER_TYPE_VIDEO && frm->type == I_FRAME) { @@ -1247,7 +1247,7 @@ static int fill_packet(muxer_t *muxer, muxer_stream_t *s, int finalize) len += m; spriv->pack_offset += m; frm->pos += m; - + if(frm->pos == frm->size) //end of frame { frm->pos = frm->size = 0; @@ -1274,14 +1274,14 @@ static int fill_packet(muxer_t *muxer, muxer_stream_t *s, int finalize) if(s->type == MUXER_TYPE_AUDIO && s->wf->wFormatTag == AUDIO_A52) fix_a52_headers(s); - + if(spriv->pack_offset < priv->packet_size && !priv->rawpes) //here finalize is set { int diff = priv->packet_size - spriv->pack_offset; write_pes_padding(&(spriv->pack[spriv->pack_offset]), diff); spriv->pack_offset += diff; } - + stream_write_buffer(muxer->stream, spriv->pack, spriv->pack_offset); priv->headers_size += spriv->pack_offset - len; @@ -1293,7 +1293,7 @@ static int fill_packet(muxer_t *muxer, muxer_stream_t *s, int finalize) spriv->frames = 0; if(write_psm) priv->last_psm_scr = priv->scr; - + return len; } @@ -1308,7 +1308,7 @@ static inline int find_best_stream(muxer_t *muxer) ndts = -1; perc = -1; - + //THIS RULE MUST ALWAYS apply: dts <= SCR + 0.7 seconds for(i = 0; i < muxer->avih.dwStreams; i++) { @@ -1316,7 +1316,7 @@ static inline int find_best_stream(muxer_t *muxer) p.len = 0; get_packet_stats(priv, muxer->streams[i], &p, 0); - + if(spriv->track_bufsize + p.len > spriv->max_buffer_size) continue; if(p.frame_pts && p.frame_dts > priv->scr + 63000*300) @@ -1350,20 +1350,20 @@ static void patch_seq(muxer_priv_t *priv, unsigned char *buf) buf[5] &= 0x0f; buf[5] |= (priv->vwidth & 0x0f) << 4; } - + if(priv->vheight > 0) { buf[5] &= 0xf0; buf[5] |= (priv->vheight >> 8) & 0x0f; buf[6] = priv->vheight & 0xff; } - + if(priv->vaspect > 0) buf[7] = (buf[7] & 0x0f) | (priv->vaspect << 4); - + if(priv->vframerate > 0) buf[7] = (buf[7] & 0xf0) | priv->vframerate; - + if(priv->vbitrate > 0) { buf[8] = (priv->vbitrate >> 10); @@ -1374,20 +1374,20 @@ static void patch_seq(muxer_priv_t *priv, unsigned char *buf) static void patch_panscan(muxer_priv_t *priv, unsigned char *buf) { //patches sequence display extension (display_horizontal_size and display_vertical_size) - //1: + //1: int offset = 1; - + if(buf[0] & 0x01) offset += 3; - + if(priv->panscan_width > 0) { buf[offset] = (priv->panscan_width >> 6); buf[offset+1] = ((priv->panscan_width & 0x3F) << 2) | (buf[offset + 1] & 0x03); } - + offset++; - + if(priv->panscan_height > 0) { buf[offset] = (priv->panscan_height >> 13) << 7; @@ -1416,7 +1416,7 @@ static void update_scr(muxer_t *muxer) } mp_msg(MSGT_MUXER, MSGL_DBG2, "UPDATE SCR TO %"PRIu64" (%.3lf)\n", priv->scr, (double) (priv->scr/27000000.0)); - + for(i = 0; i < muxer->avih.dwStreams; i++) { stream = muxer->streams[i]; @@ -1455,7 +1455,7 @@ static void update_scr(muxer_t *muxer) static int calc_frames_to_flush(muxer_headers_t *vpriv) { int n, found = 0; - + if(vpriv->framebuf_used > 0) { n = 0; @@ -1466,7 +1466,7 @@ static int calc_frames_to_flush(muxer_headers_t *vpriv) mp_msg(MSGT_MUXER, MSGL_DBG2, "CALC_FRAMES, n=%d, type=%c, pts=%.3lf\n", n, FTYPE(vpriv->framebuf[n].type), (double)vpriv->framebuf[n].pts/27000000.0f); if(n+1 < vpriv->framebuf_used) mp_msg(MSGT_MUXER, MSGL_DBG2, "n+1=%d, type=%c, pts=%.3lf\n", n+1, FTYPE(vpriv->framebuf[n+1].type), (double)vpriv->framebuf[n+1].pts/27000000.0f); - + if(vpriv->framebuf[n].type == I_FRAME) { if(n > 0) @@ -1479,7 +1479,7 @@ static int calc_frames_to_flush(muxer_headers_t *vpriv) n++; } } - + if(found && (n < vpriv->framebuf_used+1)) return n; else @@ -1496,8 +1496,8 @@ static int flush_buffers(muxer_t *muxer, int finalize) muxer_priv_t *priv = (muxer_priv_t *) muxer->priv; double duration; uint64_t iduration, iaduration; - - /* + + /* analyzes all streams and decides what to flush trying to respect an interleaving distribution equal to the v_bitrate/a_bitrate proportion @@ -1519,7 +1519,7 @@ static int flush_buffers(muxer_t *muxer, int finalize) else if(s->type == MUXER_TYPE_AUDIO) as = s; } - + if((! found) && finalize) { if(vpriv != NULL) @@ -1531,13 +1531,13 @@ static int flush_buffers(muxer_t *muxer, int finalize) mp_msg(MSGT_MUXER, MSGL_DBG2, "\nVIDEO, FLUSH %d frames (of %d), 0 to %d\n", n, vpriv->framebuf_used, n-1); vpriv = (muxer_headers_t*) vs->priv; - + duration = 0; iduration = 0; for(i = 0; i < n; i++) iduration += vpriv->framebuf[i].idur; duration = (double) (iduration / 27000000.0); - + if(as != NULL) { apriv = (muxer_headers_t*) as->priv; @@ -1552,11 +1552,11 @@ static int flush_buffers(muxer_t *muxer, int finalize) return 0; } } - + if(as != NULL && (apriv->size == 0)) { init_delay = vpriv->framebuf[0].pts - vpriv->framebuf[0].dts; - + for(i = 0; i < apriv->framebuf_cnt; i++) { apriv->framebuf[i].pts += init_delay; @@ -1565,13 +1565,13 @@ static int flush_buffers(muxer_t *muxer, int finalize) apriv->last_pts += init_delay; mp_msg(MSGT_MUXER, MSGL_DBG2, "\r\nINITIAL VIDEO DELAY: %.3lf, currAPTS: %.3lf\r\n", (double) init_delay/27000000.0f, (double) apriv->last_pts/27000000.0f); } - + if((priv->is_xvcd || priv->is_xsvcd) && (vpriv->size == 0)) vpriv->buffer_size = (conf_vbuf_size ? conf_vbuf_size : (priv->is_xvcd ? 46 : 230))*1024; - + i = 0; skip_cnt = 0; - + while(1) { update_scr(muxer); @@ -1588,7 +1588,7 @@ static int flush_buffers(muxer_t *muxer, int finalize) } } } - + muxer->file_end = priv->scr; return found; } @@ -1598,7 +1598,7 @@ static inline uint64_t parse_fps(float fps) { // 90000 * 300 * 1001 / d , there's no rounding error with any of the admitted framerates int d = (int)(fps*1001+0.5); - + return 27027000000ULL / d; } @@ -1612,8 +1612,8 @@ static int soft_telecine(muxer_priv_t *priv, muxer_headers_t *vpriv, uint8_t *fp *fps_ptr = (*fps_ptr & 0xf0) | priv->vframerate; vpriv->nom_delta_pts = parse_fps(conf_vframerate); } - - //in pce_ptr starting from bit 0 bit 24 is tff, bit 30 is rff, + + //in pce_ptr starting from bit 0 bit 24 is tff, bit 30 is rff, if(pce_ptr[3] & 0x2) { mp_msg(MSGT_MUXER, MSGL_ERR, "\nERROR! RFF bit is already set, disabling telecining\n"); @@ -1625,15 +1625,15 @@ static int soft_telecine(muxer_priv_t *priv, muxer_headers_t *vpriv, uint8_t *fp vpriv->picture.progressive_frame = 1; if(se_ptr) se_ptr[1] &= 0xf7; - + //disable tff and rff and overwrite them with the value in bff_mask pce_ptr[3] = (pce_ptr[3] & 0x7d) | priv->bff_mask[vpriv->display_frame % MAX_PATTERN_LENGTH]; pce_ptr[4] |= 0x80; //sets progressive frame - + vpriv->display_frame += n; if(! vpriv->vframes) mp_msg(MSGT_MUXER, MSGL_INFO, "\nENABLED SOFT TELECINING, FPS=%.3f\n",conf_vframerate); - + return 1; } @@ -1647,9 +1647,9 @@ static size_t parse_mpeg12_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_he int i, err; uint32_t temp_ref; int pt; - + mp_msg(MSGT_MUXER, MSGL_DBG2,"parse_mpeg12_video, len=%u\n", (uint32_t) len); - if(s->buffer[0] != 0 || s->buffer[1] != 0 || s->buffer[2] != 1 || len<6) + if(s->buffer[0] != 0 || s->buffer[1] != 0 || s->buffer[2] != 1 || len<6) { mp_msg(MSGT_MUXER, MSGL_ERR,"Unknown video format, possibly non-MPEG1/2 stream, len=%d!\n", len); return 0; @@ -1675,7 +1675,7 @@ static size_t parse_mpeg12_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_he fps_ptr = &(s->buffer[i+7]); mp_header_process_sequence_header(&(spriv->picture), &(s->buffer[i+4])); spriv->delta_pts = spriv->nom_delta_pts = parse_fps(spriv->picture.fps); - + spriv->delta_clock = (double) 1/fps; //the 2 lines below are needed to handle non-standard frame rates (such as 18) if(! spriv->delta_pts) @@ -1705,11 +1705,11 @@ static size_t parse_mpeg12_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_he pce_ptr = &(s->buffer[i+4]); } break; - + case 0xb8: gop_reset = 1; break; - + case 0x00: if(i + 5 > len) { @@ -1727,9 +1727,9 @@ static size_t parse_mpeg12_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_he } if(err) mp_msg(MSGT_MUXER, MSGL_ERR,"Warning: picture too short or broken!\n"); - + //following 2 lines are workaround: lavf doesn't sync to sequence headers before passing demux_packets - if(!spriv->nom_delta_pts) + if(!spriv->nom_delta_pts) spriv->delta_pts = spriv->nom_delta_pts = parse_fps(fps); if(!spriv->vframes) spriv->last_tr = spriv->max_tr = temp_ref; @@ -1744,28 +1744,28 @@ static size_t parse_mpeg12_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_he frames_diff = spriv->max_tr + 1 + spriv->last_tr - temp_ref; else if(!d1) //pre-emptive fix against broken sequences frames_diff = 1; - else + else frames_diff = d1; } - mp_msg(MSGT_MUXER, MSGL_DBG2, "\nLAST: %d, TR: %d, GOP: %d, DIFF: %d, MAX: %d, d1: %d\n", + mp_msg(MSGT_MUXER, MSGL_DBG2, "\nLAST: %d, TR: %d, GOP: %d, DIFF: %d, MAX: %d, d1: %d\n", spriv->last_tr, temp_ref, gop_reset, frames_diff, spriv->max_tr, d1); if(temp_ref > spriv->max_tr || gop_reset) spriv->max_tr = temp_ref; - + spriv->last_tr = temp_ref; - if(spriv->picture.mpeg1 == 0) + if(spriv->picture.mpeg1 == 0) { if(spriv->telecine && pce_ptr) { soft_telecine(priv, spriv, fps_ptr, se_ptr, pce_ptr, frames_diff); spriv->picture.display_time = 100; mp_header_process_extension(&(spriv->picture), pce_ptr); - if(spriv->picture.display_time >= 50 && spriv->picture.display_time <= 300) + if(spriv->picture.display_time >= 50 && spriv->picture.display_time <= 300) spriv->delta_pts = (spriv->nom_delta_pts * spriv->picture.display_time) / 100; } } - + if(! spriv->vframes) frames_diff = 1; @@ -1779,18 +1779,18 @@ static size_t parse_mpeg12_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_he return 0; } mp_msg(MSGT_MUXER, MSGL_DBG2, "\r\nVIDEO FRAME, PT: %C, tr: %d, diff: %d, dts: %.3lf, pts: %.3lf, pdt: %u, gop_reset: %d\r\n", - ftypes[pt], temp_ref, frames_diff, ((double) spriv->last_dts/27000000.0f), + ftypes[pt], temp_ref, frames_diff, ((double) spriv->last_dts/27000000.0f), ((double) spriv->last_pts/27000000.0f), spriv->picture.display_time, gop_reset); if(pt == B_FRAME) { int j, n, adj = 0; int64_t diff = spriv->last_dts - spriv->last_pts; - + if(diff != 0) { n = spriv->framebuf_used - 1; - + for(j = n; j >= 0; j--) { if(spriv->framebuf[j].pts >= spriv->last_pts) @@ -1805,7 +1805,7 @@ static size_t parse_mpeg12_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_he } } spriv->vframes++; - + mp_msg(MSGT_MUXER, MSGL_DBG2,"parse_mpeg12_video, return %u\n", (uint32_t) len); return len; } @@ -1817,7 +1817,7 @@ static uint64_t fix_mp4_frame_duration(muxer_headers_t *vpriv) uint32_t i; mn = mx = vpriv->framebuf[0].pts; - for(i = 0; i < 3; i++) + for(i = 0; i < 3; i++) { mp_msg(MSGT_DECVIDEO,MSGL_DBG2, "PTS: %"PRIu64"\n", vpriv->framebuf[i].pts); if(vpriv->framebuf[i].pts < mn) @@ -1826,12 +1826,12 @@ static uint64_t fix_mp4_frame_duration(muxer_headers_t *vpriv) mx = vpriv->framebuf[i].pts; } md = mn; - for(i=0; i<3; i++) + for(i=0; i<3; i++) { if((vpriv->framebuf[i].pts > mn) && (vpriv->framebuf[i].pts < mx)) md = vpriv->framebuf[i].pts; } - + if(mx - md > md - mn) diff = md - mn; else @@ -1840,11 +1840,11 @@ static uint64_t fix_mp4_frame_duration(muxer_headers_t *vpriv) mp_msg(MSGT_DECVIDEO,MSGL_DBG2, "MIN: %"PRIu64", mid: %"PRIu64", max: %"PRIu64", diff: %"PRIu64"\n", mn, md, mx, diff); if(diff > 0) { - for(i=0; i<3; i++) + for(i=0; i<3; i++) { vpriv->framebuf[i].pts += diff; vpriv->framebuf[i].dts += i * diff; - mp_msg(MSGT_MUXER, MSGL_DBG2, "FIXED_PTS: %.3lf, FIXED_DTS: %.3lf\n", + mp_msg(MSGT_MUXER, MSGL_DBG2, "FIXED_PTS: %.3lf, FIXED_DTS: %.3lf\n", (double) (vpriv->framebuf[i].pts/27000000.0), (double) (vpriv->framebuf[i].dts/27000000.0)); } return diff; @@ -1860,14 +1860,14 @@ static size_t parse_mpeg4_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_hea int64_t delta_pts=0; uint8_t pt; int ret; - + mp_msg(MSGT_MUXER, MSGL_DBG2,"parse_mpeg4_video, len=%u\n", (uint32_t) len); - if(len<6) + if(len<6) { mp_msg(MSGT_MUXER, MSGL_ERR,"Frame too short: %d, exit!\n", len); return 0; } - + pt = 0; while(ptr < len - 5) { @@ -1876,7 +1876,7 @@ static size_t parse_mpeg4_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_hea ptr++; continue; } - + if(s->buffer[ptr+3] >= 0x20 && s->buffer[ptr+3] <= 0x2f) //VOL { mp4_header_process_vol(&(vpriv->picture), &(s->buffer[ptr+4])); @@ -1889,42 +1889,42 @@ static size_t parse_mpeg4_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_hea { int32_t delta; mp4_header_process_vop(&(vpriv->picture), &(s->buffer[ptr+4])); - + delta = vpriv->picture.timeinc_unit - vpriv->last_tr; if((delta > 0) && (delta > (vpriv->picture.timeinc_resolution/2))) delta -= vpriv->picture.timeinc_resolution; else if((delta < 0) && (delta < (-(vpriv->picture.timeinc_resolution/2)))) delta += vpriv->picture.timeinc_resolution; - + delta_pts = (27000000 * (int64_t) delta) / vpriv->picture.timeinc_resolution; //warning, it seems that packed bops can lead to delta == 0 - + pt = vpriv->picture.picture_type + 1; - mp_msg(MSGT_MUXER, MSGL_DBG2, "\nTYPE: %c, RESOLUTION: %d, TEMP: %d, delta: %d, delta_pts: %"PRId64" = %.3lf, delta2: %.3lf\n", + mp_msg(MSGT_MUXER, MSGL_DBG2, "\nTYPE: %c, RESOLUTION: %d, TEMP: %d, delta: %d, delta_pts: %"PRId64" = %.3lf, delta2: %.3lf\n", FTYPE(pt), vpriv->picture.timeinc_resolution, vpriv->picture.timeinc_unit, delta, delta_pts, (double) (delta_pts/27000000.0), (double) delta / (double) vpriv->picture.timeinc_resolution); - - vpriv->last_tr = vpriv->picture.timeinc_unit; - + + vpriv->last_tr = vpriv->picture.timeinc_unit; + break; } - + ptr++; } - + if(vpriv->vframes) { vpriv->last_dts += vpriv->frame_duration; vpriv->last_pts += delta_pts; } - + ret = add_frame(vpriv, delta_pts, s->buffer, len, pt, vpriv->last_dts, vpriv->last_pts); if(ret < 0) { mp_msg(MSGT_MUXER, MSGL_FATAL, "\r\nPARSE_MPEG4: add_frames(%d) failed, exit\r\n", len); return 0; } - + if(!vpriv->frame_duration && vpriv->framebuf_used == 3) { vpriv->frame_duration = fix_mp4_frame_duration(vpriv); @@ -1933,17 +1933,17 @@ static size_t parse_mpeg4_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_hea vpriv->last_pts += vpriv->frame_duration; vpriv->last_dts = vpriv->framebuf[vpriv->framebuf_used-1].dts; vpriv->delta_clock = ((double) vpriv->frame_duration)/27000000.0; - mp_msg(MSGT_MUXER, MSGL_INFO, "FRAME DURATION: %"PRIu64" %.3lf\n", + mp_msg(MSGT_MUXER, MSGL_INFO, "FRAME DURATION: %"PRIu64" %.3lf\n", vpriv->frame_duration, (double) (vpriv->frame_duration/27000000.0)); vpriv->is_ready = 1; } } - - mp_msg(MSGT_MUXER, MSGL_DBG2, "LAST_PTS: %.3lf, LAST_DTS: %.3lf\n", + + mp_msg(MSGT_MUXER, MSGL_DBG2, "LAST_PTS: %.3lf, LAST_DTS: %.3lf\n", (double) (vpriv->last_pts/27000000.0), (double) (vpriv->last_dts/27000000.0)); vpriv->vframes++; - + return len; } @@ -1954,7 +1954,7 @@ static int fill_last_frame(muxer_headers_t *spriv, uint8_t *ptr, int len) if(!len) return 0; - + if(spriv->framebuf_used == 0) idx = spriv->framebuf_used; else @@ -1989,21 +1989,21 @@ static int add_frame(muxer_headers_t *spriv, uint64_t idur, uint8_t *ptr, int le mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't realloc frame buffer(idx), abort\n"); return -1; } - + spriv->framebuf[spriv->framebuf_cnt].size = 0; spriv->framebuf[spriv->framebuf_cnt].alloc_size = 0; spriv->framebuf[spriv->framebuf_cnt].pos = 0; - + spriv->framebuf[spriv->framebuf_cnt].buffer = (uint8_t*) malloc(len); if(spriv->framebuf[spriv->framebuf_cnt].buffer == NULL) { mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't realloc frame buffer(frame), abort\n"); return -1; } - spriv->framebuf[spriv->framebuf_cnt].alloc_size = len; + spriv->framebuf[spriv->framebuf_cnt].alloc_size = len; spriv->framebuf_cnt++; } - + if(spriv->framebuf[idx].alloc_size < spriv->framebuf[idx].size + len) { if(spriv->framebuf[idx].size > SIZE_MAX - (size_t)len) @@ -2019,7 +2019,7 @@ static int add_frame(muxer_headers_t *spriv, uint64_t idur, uint8_t *ptr, int le } spriv->framebuf[idx].alloc_size = spriv->framebuf[idx].size + len; } - + memcpy(&(spriv->framebuf[idx].buffer[spriv->framebuf[idx].size]), ptr, len); spriv->framebuf[idx].size += len; spriv->framebuf[idx].pos = 0; @@ -2038,7 +2038,7 @@ static int analyze_mpa(muxer_stream_t *s) { int i = 0, len, max, chans, srate, spf, layer; int score[4] = {0, 0, 0, 0}; - + while(i < s->b_buffer_len + 3) { if(s->b_buffer[i] == 0xFF && ((s->b_buffer[i+1] & 0xE0) == 0xE0)) @@ -2093,11 +2093,11 @@ static int parse_audio(muxer_stream_t *s, int finalize, unsigned int *nf, double finished = 1; break; } - + if(s->b_buffer[i] == 0xFF && ((s->b_buffer[i+1] & 0xE0) == 0xE0)) { len = mp_get_mp3_header(&(s->b_buffer[i]), &chans, &srate, &spf, &layer, NULL); - if(len > 0 && (srate == s->wf->nSamplesPerSec) && (i + len <= s->b_buffer_len) + if(len > 0 && (srate == s->wf->nSamplesPerSec) && (i + len <= s->b_buffer_len) && layer == spriv->mpa_layer) { dur = (double) spf / (double) srate; @@ -2116,7 +2116,7 @@ static int parse_audio(muxer_stream_t *s, int finalize, unsigned int *nf, double finished = 1; break; } - + if(s->b_buffer[i] == 0x0B && s->b_buffer[i+1] == 0x77) { srate = 0; @@ -2144,7 +2144,7 @@ static int parse_audio(muxer_stream_t *s, int finalize, unsigned int *nf, double finished = 1; break; } - + if(s->b_buffer[i] == 0xFF && ((s->b_buffer[i+1] & 0xF6) == 0xF0)) { len = aac_parse_frame(&(s->b_buffer[i]), &srate, &num); @@ -2167,7 +2167,7 @@ static int parse_audio(muxer_stream_t *s, int finalize, unsigned int *nf, double i++; continue; } - + spriv->timer += dur; if(spriv->drop_delayed_frames && delay < 0 && spriv->timer <= -delay) { @@ -2265,7 +2265,7 @@ static void fix_parameters(muxer_stream_t *stream) else spriv->max_buffer_size = 232*1024; //no profile => unconstrained :) FIXME!!! } - + if(is_mpeg4(stream->bih->biCompression)) spriv->is_ready = 0; else @@ -2274,7 +2274,7 @@ static void fix_parameters(muxer_stream_t *stream) if(!is_mpeg1(stream_format) && !is_mpeg2(stream_format)) needs_psm = 1; } - + if(priv->is_genmpeg2 && needs_psm) { priv->use_psm = 1; @@ -2321,7 +2321,7 @@ static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags spriv->last_dts += tmp; } } - else if(is_mpeg4(stream_format)) + else if(is_mpeg4(stream_format)) { spriv->is_mpeg12 = 0; spriv->telecine = 0; @@ -2334,7 +2334,7 @@ static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags 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 @@ -2342,7 +2342,7 @@ static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags double fake_timer; spriv->type = 0; stream_format = s->wf->wFormatTag; - + if(s->b_buffer_size - s->b_buffer_len < len) { void *tmp; @@ -2359,13 +2359,13 @@ static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags return; } s->b_buffer = tmp; - + 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) @@ -2379,7 +2379,7 @@ static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags 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); + mp_msg(MSGT_MUXER, MSGL_INFO, "AINIT: %.3lf\r\n", (double) spriv->last_pts/27000000.0f); } } @@ -2407,25 +2407,25 @@ static void mpegfile_write_index(muxer_t *muxer) priv->scr = 0; write_mpeg_pack(muxer, NULL, muxer->stream, 1); //insert fake Nav Packet } - + mp_msg(MSGT_MUXER, MSGL_INFO, "\nOverhead: %.3lf%% (%"PRIu64" / %"PRIu64")\n", 100.0 * (double)priv->headers_size / (double)priv->data_size, priv->headers_size, priv->data_size); } static void mpegfile_write_header(muxer_t *muxer) { muxer_priv_t *priv = (muxer_priv_t*) muxer->priv; - + mp_tmsg(MSGT_MUXER, MSGL_INFO, "Writing header...\n"); - + priv->headers_cnt++; - + //write the first system header only for generic mpeg1/2 muxes, and only when we have collected all necessary infos if(priv->is_genmpeg1 || priv->is_genmpeg2 || ((priv->is_xvcd || priv->is_xsvcd) && (priv->headers_cnt == 1))) { write_mpeg_pack(muxer, NULL, muxer->stream, 0); priv->update_system_header = 0; } - + return; } @@ -2438,19 +2438,19 @@ static void setup_sys_params(muxer_priv_t *priv) int a2 = (conf_abuf_size>58 ? conf_abuf_size : 58); priv->sys_info.cnt = 4; - + priv->sys_info.streams[0].id = 0xb9; priv->sys_info.streams[0].type = 1; priv->sys_info.streams[0].bufsize = v*1024; - + priv->sys_info.streams[1].id = 0xb8; priv->sys_info.streams[1].type = 0; priv->sys_info.streams[1].bufsize = a1*1024; - + priv->sys_info.streams[2].id = 0xbd; priv->sys_info.streams[2].type = 1; priv->sys_info.streams[2].bufsize = a2*1024; - + priv->sys_info.streams[3].id = 0xbf; priv->sys_info.streams[3].type = 1; priv->sys_info.streams[3].bufsize = 2*1024; @@ -2461,11 +2461,11 @@ static void setup_sys_params(muxer_priv_t *priv) int a1 = (conf_abuf_size ? conf_abuf_size : 4); priv->sys_info.cnt = 2; - + priv->sys_info.streams[0].id = 0xe0; priv->sys_info.streams[0].type = 1; priv->sys_info.streams[0].bufsize = v*1024; - + priv->sys_info.streams[1].id = 0xc0; priv->sys_info.streams[1].type = 0; priv->sys_info.streams[1].bufsize = a1*1024; @@ -2480,10 +2480,10 @@ static void generate_flags(uint8_t *bff_mask, int source, int target) unsigned int i, trfp; uint64_t dfl,tfl; unsigned char ormask[4] = {0x0, 0x2, 0x80, 0x82}; - + dfl = (target - source) << 1; tfl = source >> 1; - + trfp = 0; for(i = 0; i < MAX_PATTERN_LENGTH; i++) { @@ -2506,9 +2506,9 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) 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")) @@ -2567,7 +2567,7 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) priv->muxrate = 1800 * 125; //Constrained parameters } } - + if(conf_ts_allframes) priv->ts_allframes = 1; if(conf_muxrate > 0) @@ -2577,7 +2577,7 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) 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); @@ -2592,14 +2592,14 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) 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; @@ -2612,11 +2612,11 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) 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; - + sfps = (int) (conf_telecine_src * 1001 + 0.5); tfps = (int) (conf_telecine_dest * 1001 + 0.5); if(sfps % 2 || tfps % 2) @@ -2624,7 +2624,7 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) 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"); @@ -2637,11 +2637,11 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) conf_vframerate = conf_telecine_dest; } } - + if(conf_vframerate) { int fps; - + fps = (int) (conf_vframerate * 1001 + 0.5); switch(fps) { @@ -2678,13 +2678,13 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) } } } - + 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; @@ -2702,12 +2702,12 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) 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"); @@ -2715,16 +2715,16 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) } 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; @@ -2733,4 +2733,3 @@ int muxer_init_muxer_mpeg(muxer_t *muxer) muxer->fix_stream_parameters = &fix_parameters; return 1; } - |