Ticket #2252: replex.diff
File replex.diff, 3.7 KB (added by , 18 years ago) |
---|
-
element.h
115 115 uint32_t mode_extension; 116 116 uint32_t emphasis; 117 117 uint32_t framesize; 118 uint32_t frametime; 118 119 uint32_t off; 119 120 } audio_frame_t; 120 121 -
replex.c
117 117 while (c < len){ 118 118 if ( (pos = find_audio_sync(rbuf, buf, c+off, type, len-c) ) 119 119 >= 0 ){ 120 120 if (!aframe->set){ 121 121 switch( type ){ 122 122 case AC3: 123 123 re = get_ac3_info(rbuf, aframe, … … 183 183 } 184 184 } 185 185 186 if (aframe->set && rx->fix_sync && first){ 187 int frame_time = aframe->frametime; 188 int64_t diff; 189 diff = ptsdiff(trans_pts_dts(p->pts), add_pts_audio(0, aframe,*acount + 1) + *fpts); 190 if (abs ((int)diff) >= frame_time){ 191 fprintf(stderr,"fixing audio PTS inconsistency - diff: "); 192 printpts(abs(diff)); 193 fprintf(stderr,"\n"); 186 194 195 if (diff < 0){ 196 diff = abs(diff); 197 int framesdiff = diff / frame_time; 198 fprintf(stderr, "need to remove %d frame(s)\n", framesdiff); 199 //FIXME need to remove audio frame(s) here 200 iu->pts = add_pts_audio(0, aframe, -framesdiff); 201 } else { 202 int framesdiff = diff / frame_time; 203 fprintf(stderr, "need to add %d frame(s)\n", framesdiff); 204 205 // get a copy of the current audio frame 206 uint8_t *framebuf; 207 if ( !(framebuf = (uint8_t *) malloc(sizeof(uint8_t *) * aframe->framesize))) { 208 fprintf(stderr,"Not enough memory for audio frame\n"); 209 exit(1); 210 } 211 212 int res; 213 res = ring_peek(rbuf, framebuf, aframe->framesize, 0); 214 if (res != aframe->framesize) { 215 fprintf(stderr,"ring buffer failed to peek frame res: %d\n", res); 216 exit(1); 217 } 218 219 // add each extra frame required direct to the output file 220 int x; 221 for (x = 0; x < framesdiff; x++){ 222 //FIXME need to fix for ac3 streams 223 write(rx->dmx_out[num+1], framebuf, aframe->framesize); 224 *acount += 1; 225 } 226 } 227 } 228 } 229 187 230 if (aframe->set){ 188 231 if(iu->active){ 189 232 iu->length = ring_posdiff(rbuf, 190 233 iu->start, 191 234 p->ini_pos + 192 235 pos+c); 193 if (iu->length < aframe->framesize || 236 237 if (iu->length < aframe->framesize || 194 238 iu->length > aframe->framesize+1){ 195 239 fprintf(stderr,"Wrong audio frame size: %d\n", iu->length); 196 240 iu->err= FRAME_ERR; … … 2351 2395 } 2352 2396 fprintf(stderr,"AC3%d output File is: %s\n",i,fname); 2353 2397 } 2354 do_demux(&rx); 2398 // FIXME 2399 rx.fix_sync = 1; 2400 do_demux(&rx); 2355 2401 } else if (analyze){ 2356 2402 rx.demux=1; 2357 2403 do_analyze(&rx); -
replex.h
45 45 int otype; 46 46 int ignore_pts; 47 47 int keep_pts; 48 int fix_sync; 48 49 uint64_t inflength; 49 50 uint64_t finread; 50 51 int lastper; -
element.c
517 517 af->off = c; 518 518 af->set = 1; 519 519 520 af->frametime = ((samples [3-af->layer] * 27000000ULL) / af->frequency); 520 521 af->framesize = af->bit_rate *slots [3-af->layer]/ af->frequency; 521 522 fprintf(stderr," frame size: %d (", af->framesize); 522 printpts( ((samples [3-af->layer] * 27000000ULL) 523 / af->frequency)); 523 printpts(af->frametime); 524 524 fprintf(stderr,") "); 525 525 526 526 return c; … … 572 572 573 573 af->off = c; 574 574 af->set = 1; 575 return c; 575 576 //FIXME calculate frametime 577 af->frametime = 0; 578 579 return c; 576 580 } 577 581 578 582