comparison libmpdemux/muxer_mpeg.c @ 18166:e952e8cdf98e

removed useless (and broken as hell) buffering code from muxer1; buffering constraints will be fully respected when one of the forthcoming patches is applied
author nicodvb
date Thu, 20 Apr 2006 21:40:03 +0000
parents 471ccd7705d6
children afaa492536f6
comparison
equal deleted inserted replaced
18165:471ccd7705d6 18166:e952e8cdf98e
197 priv->sys_info.streams[i].id = newid; 197 priv->sys_info.streams[i].id = newid;
198 priv->sys_info.streams[i].type = 1; 198 priv->sys_info.streams[i].type = 1;
199 priv->sys_info.streams[i].bufsize = size; 199 priv->sys_info.streams[i].bufsize = size;
200 } 200 }
201 } 201 }
202 }
203
204 static void fix_buffer_params(muxer_priv_t *priv, uint8_t id, uint32_t size)
205 {
206 uint8_t i;
207
208 for(i = 0; i < priv->sys_info.cnt; i++)
209 if(priv->sys_info.streams[i].id == id)
210 priv->sys_info.streams[i].bufsize = size;
211 } 202 }
212 203
213 static inline int is_mpeg1(uint32_t x) 204 static inline int is_mpeg1(uint32_t x)
214 { 205 {
215 return ( 206 return (
2017 spriv->delta_pts = spriv->nom_delta_pts; 2008 spriv->delta_pts = spriv->nom_delta_pts;
2018 2009
2019 ptr = tmp; 2010 ptr = tmp;
2020 } 2011 }
2021 } 2012 }
2022
2023 switch (pt) {
2024 case 2: // predictive
2025 if (s->ipb[0]) {
2026 sz = len + s->ipb[0];
2027 s->ipb[0] = max(s->ipb[0], s->ipb[2]);
2028 s->ipb[2] = 0;
2029 } else if (s->ipb[2]) {
2030 sz = len + s->ipb[2];
2031 s->ipb[0] = s->ipb[2];
2032 s->ipb[2] = 0;
2033 } else
2034 sz = 4 * len; // no bidirectional frames yet?
2035
2036 s->ipb[1] = len;
2037 break;
2038 case 3: // bidirectional
2039 s->ipb[2] += len;
2040 sz = s->ipb[1] + s->ipb[2];
2041 break;
2042 default: // intra-coded
2043 sz = len; // no extra buffer for it...
2044 }
2045 2013
2046 spriv->vframes++; 2014 spriv->vframes++;
2047 add_frame(spriv, spriv->delta_pts, s->buffer, len, pt, temp_ref); 2015 add_frame(spriv, spriv->delta_pts, s->buffer, len, pt, temp_ref);
2048 } 2016 }
2049 2017
2050 mp_msg(MSGT_MUXER, MSGL_DBG2,"parse_mpeg12_video, return %u\n", (uint32_t) len); 2018 mp_msg(MSGT_MUXER, MSGL_DBG2,"parse_mpeg12_video, return %u\n", (uint32_t) len);
2051 return sz; 2019 return len;
2052 } 2020 }
2053 2021
2054 2022
2055 static uint64_t fix_mp4_frame_duration(muxer_headers_t *vpriv) 2023 static uint64_t fix_mp4_frame_duration(muxer_headers_t *vpriv)
2056 { 2024 {
2522 parse_audio(s, 0, &nf, &fake_timer); 2490 parse_audio(s, 0, &nf, &fake_timer);
2523 sz = max(len, 2 * priv->packet_size); 2491 sz = max(len, 2 * priv->packet_size);
2524 } 2492 }
2525 2493
2526 2494
2527 //if genmpeg1/2 and sz > last buffer size in the system header we must write the new sysheader
2528 if(sz > s->h.dwSuggestedBufferSize) { // increase and set STD
2529 s->h.dwSuggestedBufferSize = sz;
2530 if(priv->is_genmpeg1 || priv->is_genmpeg2) {
2531 fix_buffer_params(priv, spriv->id, s->h.dwSuggestedBufferSize);
2532 priv->update_system_header = 1;
2533 }
2534 }
2535
2536 if(spriv->psm_fixed == 0) { 2495 if(spriv->psm_fixed == 0) {
2537 add_to_psm(priv, spriv->id, stream_format); 2496 add_to_psm(priv, spriv->id, stream_format);
2538 spriv->psm_fixed = 1; 2497 spriv->psm_fixed = 1;
2539 priv->psm_streams_cnt++; 2498 priv->psm_streams_cnt++;
2540 if((priv->psm_streams_cnt == muxer->num_videos + muxer->num_audios) && priv->use_psm) 2499 if((priv->psm_streams_cnt == muxer->num_videos + muxer->num_audios) && priv->use_psm)