~ubuntu-branches/ubuntu/hardy/avidemux/hardy

« back to all changes in this revision

Viewing changes to avidemux/ADM_mpegdemuxer/dmx_audio.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2006-12-15 17:13:20 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061215171320-w79pvpehxx2fr217
Tags: 1:2.3.0-0.0ubuntu1
* Merge from debian-multimedia.org, remaining Ubuntu change:
  - desktop file,
  - no support for ccache and make -j.
* Closes Ubuntu: #69614.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include "dmx_audio.h"
41
41
#include "ADM_audio/ADM_mp3info.h"
42
42
#include "ADM_audio/ADM_a52info.h"
 
43
#include "ADM_audio/ADM_dcainfo.h"
43
44
#define MAX_LINE 4096
44
45
#define PROBE_SIZE (4096*2)
45
46
 
144
145
        return 0;
145
146
  }
146
147
  _tracks=new dmxAudioTrack[nbAudioStream];
 
148
  memset(_tracks,0,sizeof(dmxAudioTrack)*nbAudioStream);
147
149
  nbTrack=nbAudioStream;
148
150
  _index=new dmxAudioIndex[nbGop+1];
149
151
  fgets (string, MAX_LINE, file);
179
181
                track.pid=_tracks[mainAudio].myPid;
180
182
  switch (type)
181
183
    {
 
184
    case 'M':
 
185
                demuxer = new dmx_demuxerMSDVR (1,&track,0);
 
186
                break;
182
187
    case 'P':
183
188
                demuxer = new dmx_demuxerPS (1,&track,multi);
184
189
                break;
233
238
      
234
239
      read++;
235
240
    }
 
241
    // now read offset
 
242
    {
 
243
    int trackNo,offset,pts;
 
244
    while(1)
 
245
    {
 
246
        if (!fgets (string, MAX_LINE, file))
 
247
            break;
 
248
        if(strncmp(string,"# track ",8)) continue;
 
249
        if(3!=sscanf(string,"# track %d PTS : %d  delta=%d ms",&trackNo,&pts,&offset))
 
250
        {
 
251
            printf("Error reading time offset for line [%s]\n",string);
 
252
            break;
 
253
        }
 
254
        ADM_assert(trackNo);
 
255
        ADM_assert(trackNo<nbTrack+1);
 
256
        trackNo--;
 
257
        _tracks[trackNo].avSync=offset;
 
258
        
 
259
    }
 
260
    } // /read offset
236
261
  fclose (file);
237
262
  nbIndex = read;
238
263
  if (!read)
331
356
                
332
357
                        if(_pos+size>=_length) 
333
358
                        {       
334
 
                                printf("DMX_audio Going out of bound\n");
335
 
                                return 0;
 
359
                            printf("DMX_audio Going out of bound (position : %u asked %u end%u)\n",_pos,size,_length);
 
360
                            size=_length-_pos;
 
361
                            if(_pos==_length) return 0;
336
362
                        }
337
363
                        if(!(size=demuxer->read(ptr,size)))
338
364
                        {
339
 
                                printf("DMX_audio Read failed\n");
340
 
                                 return 0;
 
365
                            printf("DMX_audio Read failed (got:%u)\n",size);
 
366
                            _pos+=size;
 
367
                            return 0;
341
368
                        }
342
369
                        _pos+=size;     
343
370
                        return size;
368
395
        }
369
396
        myPes=_tracks[i].myPes;
370
397
        // Try mp2/3
371
 
        if(myPes>=0xC0 && myPes<0xC9)
 
398
        if(myPes>=0xC0 && myPes<=0xC9)
372
399
        {
373
400
                if(getMpegFrameInfo(buffer,PROBE_SIZE,&mpegInfo,NULL,&offset))
374
401
                {
402
429
                        }
403
430
                }
404
431
        }
 
432
 
 
433
        if(myPes<=0x49 && myPes>=0x40)
 
434
        {
 
435
             
 
436
              uint32_t flags,samplerate,bitrate,framelength,syncoff,chan,nbs;
 
437
//int ADM_DCAGetInfo(uint8_t *buf, uint32_t len, uint32_t *fq, uint32_t *br, uint32_t *chan,uint32_t *syncoff,uint32_t *flags);
 
438
              if(ADM_DCAGetInfo(buffer,PROBE_SIZE,&samplerate,&bitrate,&chan,&syncoff,&flags,&nbs))
 
439
              {
 
440
                                hdr->byterate=bitrate/8;
 
441
                                hdr->frequency=samplerate;
 
442
                                hdr->encoding=WAV_DTS;
 
443
                                hdr->channels=chan;
 
444
                                continue;
 
445
               }
 
446
        }
405
447
        // Default 48khz stereo lpcm
406
448
        if(myPes>=0xA0 && myPes<0xA9)
407
449
        {
427
469
      //
428
470
      return 1;
429
471
}
430
 
uint8_t                 dmxAudioStream::getAudioStreamsInfo(uint32_t *nbStreams, uint32_t **infos)
 
472
uint8_t                 dmxAudioStream::getAudioStreamsInfo(uint32_t *nbStreams, audioInfo **infos)
431
473
{
432
474
    *nbStreams=0;
433
475
    *infos=NULL;
434
476
    if(!nbTrack) return 1;
435
477
    *nbStreams=nbTrack;
436
 
    *infos=new uint32_t [nbTrack];
 
478
    *infos=new audioInfo [nbTrack];
437
479
    for(int i=0;i<nbTrack;i++)
438
 
        (*infos)[i]=_tracks[i].wavHeader.encoding;
 
480
    {
 
481
     //   (*infos)[i]=_tracks[i].wavHeader.encoding;
 
482
        WAV2AudioInfo(&(_tracks[i].wavHeader),&((*infos)[i]));
 
483
        (*infos)[i].av_sync=_tracks[i].avSync;
 
484
    }
439
485
    return 1;
440
486
}
441
487