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

« back to all changes in this revision

Viewing changes to avidemux/ADM_video/ADM_vidVobsub.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matvey Kozhev
  • Date: 2007-12-18 13:53:04 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218135304-cdqec2lg2bglyz15
Tags: 1:2.4~preview3-0.0ubuntu1
* Upload to Ubuntu. (LP: #163287, LP: #126572)
* debian/changelog: re-added Ubuntu releases.
* debian/control:
  - Require debhelper >= 5.0.51 (for dh_icons) and imagemagick.
  - Build-depend on libsdl1.2-dev instead of libsdl-dev.
  - Build against newer libx264-dev. (LP: #138854)
  - Removed libamrnb-dev, not in Ubuntu yet.
* debian/rules:
  - Install all icon sizes, using convert (upstream installs none).
  - Added missing calls to dh_installmenu, dh_installman, dh_icons and
    dh_desktop.
* debian/menu, debian/avidemux-qt.menu:
  - Corrected package and executable names.
* debian/avidemux-common.install: Install icons.
* debian/avidemux.common.manpages: Install man/avidemux.1.
* debian/links, debian/avidemux-cli.links, debian/avidemux-gtk.links:
  - Link manpages to avidemux.1.gz.
* debian/install, debian/avidemux-qt.install, debian/avidemux-gtk.desktop,
  debian/avidemux-qt.desktop: Install desktop files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// C++ Implementation:Spudecoder (subs for DVd like stream)
3
 
//
4
 
// Description:
5
 
//
6
 
//
7
 
// Author: Mean, fixounet@free.fr
8
 
//
9
 
// Copyright: See COPYING file that comes with this distribution
10
 
//
11
 
// see http://sam.zoy.org/writings/dvd/subtitles/
12
 
 
13
 
 
14
 
/***************************************************************************
15
 
 *                                                                         *
16
 
 *   This program is free software; you can redistribute it and/or modify  *
17
 
 *   it under the terms of the GNU General Public License as published by  *
18
 
 *   the Free Software Foundation; either version 2 of the License, or     *
19
 
 *   (at your option) any later version.                                   *
20
 
 *                                                                         *
21
 
 ***************************************************************************/
22
 
 
23
 
#include <stdio.h>
24
 
#include <stdlib.h>
25
 
#include <string.h>
26
 
#include <math.h>
27
 
#include <ADM_assert.h>
28
 
 
29
 
#include "config.h"
30
 
#include "fourcc.h"
31
 
#include "avio.hxx"
32
 
#include "config.h"
33
 
#include "avi_vars.h"
34
 
 
35
 
 
36
 
 
37
 
#include "ADM_toolkit/toolkit.hxx"
38
 
#include "ADM_editor/ADM_edit.hxx"
39
 
#include "ADM_video/ADM_genvideo.hxx"
40
 
#include "ADM_video/ADM_vidFlipV.h"
41
 
#include "ADM_filter/video_filters.h"
42
 
 
43
 
 
44
 
#include "ADM_toolkit/filesel.h"
45
 
 
46
 
#include "ADM_colorspace/colorspace.h"
47
 
 
48
 
#include "ADM_vobsubinfo.h"
49
 
 
50
 
#define VOBSUB "/capture/sub/phone.sub"
51
 
 
52
 
#include "ADM_vidVobSub.h"
53
 
 
54
 
#include "ADM_toolkit/ADM_debugID.h"
55
 
#define MODULE_NAME MODULE_FILTER
56
 
#include "ADM_toolkit/ADM_debug.h"
57
 
 
58
 
 
59
 
extern uint8_t DIA_vobsub(vobSubParam *param);
60
 
 
61
 
static FILTER_PARAM vobsubParam={3,{"subname","index","subShift"}};
62
 
//*************************************************************
63
 
//
64
 
 
65
 
//*************************************************************
66
 
SCRIPT_CREATE(vobsub_script,ADMVideoVobSub,vobsubParam);
67
 
BUILD_CREATE(vobsub_create,ADMVideoVobSub);
68
 
//*************************************************************
69
 
uint8_t ADMVideoVobSub::configure(AVDMGenericVideoStream *in)
70
 
{
71
 
 
72
 
       
73
 
  if(DIA_vobsub(_param))
74
 
       {
75
 
                cleanup();
76
 
                setup();
77
 
                return 1;
78
 
       }
79
 
        
80
 
        return 0;        
81
 
}
82
 
 
83
 
//*************************************************************
84
 
char *ADMVideoVobSub::printConf( void )
85
 
{
86
 
        static char buf[50];
87
 
        
88
 
        sprintf((char *)buf," VobSub");
89
 
        return buf;
90
 
}
91
 
//*************************************************************
92
 
ADMVideoVobSub::ADMVideoVobSub(  AVDMGenericVideoStream *in,CONFcouple *couples)
93
 
{
94
 
 
95
 
        _in=in;         
96
 
        memcpy(&_info,_in->getInfo(),sizeof(_info));    
97
 
        _info.encoding=1;       
98
 
        _parser=NULL;  
99
 
        _resampled=NULL;
100
 
        _chromaResampled=NULL;
101
 
        _original=NULL;        
102
 
        
103
 
        _param=NEW(vobSubParam);
104
 
        
105
 
        if(couples)
106
 
        {                 
107
 
                GET(subname);
108
 
                GET(index);                               
109
 
                GET(subShift);  
110
 
        }
111
 
        else
112
 
        {
113
 
#ifdef KK_ADM_DEBUG
114
 
                _param->subname=ADM_strdup(VOBSUB);
115
 
#else                
116
 
                _param->subname =NULL;
117
 
#endif                
118
 
                _param->index = 0;   
119
 
                _param->subShift=0;             
120
 
        }
121
 
        
122
 
        setup();
123
 
}
124
 
/*
125
 
    Alternate constructor for use by OCR
126
 
*/
127
 
ADMVideoVobSub::ADMVideoVobSub(  char *fileidx,uint32_t idx)
128
 
{
129
 
 
130
 
        _in=NULL;         
131
 
        memset(&_info,0,sizeof(_info));    
132
 
        _info.encoding=1;       
133
 
        _parser=NULL;  
134
 
        _resampled=NULL;
135
 
        _chromaResampled=NULL;
136
 
        _original=NULL;        
137
 
        
138
 
        _param=NEW(vobSubParam);
139
 
        
140
 
        
141
 
        _param->subname=ADM_strdup(fileidx);
142
 
        _param->index = idx;   
143
 
        _param->subShift=0;                    
144
 
        
145
 
        setup();
146
 
}
147
 
/*
148
 
    Returns bitmap & info for the Nth subs
149
 
*/
150
 
 
151
 
vobSubBitmap *ADMVideoVobSub::getBitmap(uint32_t nb,uint32_t *start, uint32_t *end,uint32_t *first,uint32_t *last)
152
 
{
153
 
uint32_t top=0,bottom=0;
154
 
    ADM_assert(_vobSubInfo);
155
 
    ADM_assert(nb<_vobSubInfo->nbLines);
156
 
    
157
 
    // Seek & decode
158
 
    //_parser->_asyncJump2(0,_vobSubInfo->lines[nb].fileOffset);
159
 
    _parser->setPos(_vobSubInfo->lines[nb].fileOffset,0);
160
 
    if(!handleSub(nb))
161
 
        {
162
 
                printf("Error reading getBimap\n");
163
 
                *first=*last=0;
164
 
                return _original; // might be null (?)
165
 
        }
166
 
    *first=*last=0;
167
 
    if(_original)
168
 
    {
169
 
    uint32_t ox,oy;
170
 
        _original->buildYUV(_YUVPalette);
171
 
        ox=_original->_width;        
172
 
        oy=_original->_height;
173
 
        printf("Original :%lu x %lu (original  %d)\n",ox,oy,_vobSubInfo->height);
174
 
        ADM_assert(oy<=_vobSubInfo->height);
175
 
        
176
 
        // Search the 1st/last non null line
177
 
//#define DONTCLIP
178
 
#ifdef DONTCLIP     
179
 
         *first=0;
180
 
         *last=oy-1;   
181
 
#else
182
 
        if(oy>_original->_height) oy=_original->_height-1;
183
 
 
184
 
        while(top<oy && !_original->isDirty(top) ) top++;
185
 
        
186
 
        if(top==oy)
187
 
        {
188
 
                top=bottom=0;   // Empty bitmap ?
189
 
                *first=top;
190
 
                *last=bottom;
191
 
                printf("Empry bitmap\n");
192
 
                return NULL; 
193
 
        }
194
 
        bottom=oy-1;
195
 
        while(bottom>top && !_original->isDirty(bottom)) bottom--;
196
 
        
197
 
        // If true it means we have 2 subs, one on top, one on bottom
198
 
        //
199
 
#if 0
200
 
        if(bottom>(oy>>1) && top<(oy>>1) && (bottom-top>(oy>>1)))
201
 
        {
202
 
          // in that case, take only the lower one
203
 
          top=oy>>1;
204
 
          while(top<oy && !_original->isDirty(top)) top++;                    
205
 
        }
206
 
        printf("> clipped: %lu / %lu=%lu\n",top,bottom,bottom-top+1);
207
 
#endif
208
 
        *first=top;
209
 
        *last=bottom;
210
 
#endif
211
 
    }
212
 
    *start=_vobSubInfo->lines[nb].startTime;
213
 
    *end=_vobSubInfo->lines[nb].stopTime;
214
 
    return _original;
215
 
}
216
 
/*
217
 
    Returns the nb of lines found in the sub
218
 
*/
219
 
uint32_t     ADMVideoVobSub::getNbImage( void)
220
 
{
221
 
    if(!_parser) return 0;
222
 
    if(!_param) return 0;
223
 
    if(!_vobSubInfo) return 0;
224
 
    return _vobSubInfo->nbLines;
225
 
 
226
 
}
227
 
//************************************
228
 
uint8_t ADMVideoVobSub::setup(void)
229
 
{
230
 
  char *dup;
231
 
  int l;
232
 
  
233
 
   _vobSubInfo=NULL;
234
 
   if(_param->subname && strlen(_param->subname)>5)
235
 
        {
236
 
                printf("Opening %s\n",_param->subname);
237
 
                dup=ADM_strdup(_param->subname);
238
 
                l=strlen(dup);
239
 
                if(l>5)
240
 
                  if(dup[l-4]=='.')
241
 
                {
242
 
                  dup[l-3]='s';
243
 
                  dup[l-2]='u';
244
 
                  dup[l-1]='b';
245
 
                          
246
 
                }
247
 
                if(vobSubRead(_param->subname,_param->index,&_vobSubInfo))
248
 
                {
249
 
                        printf("Opening index \n");
250
 
                       
251
 
                        MPEG_TRACK track;
252
 
                        memset(&track,0,sizeof(track));
253
 
                        track.pes=_param->index+0x20;
254
 
                        track.pid=0;
255
 
                       // _parser=new ADM_mpegDemuxerProgramStream(_param->index+0x20,0xe0);
256
 
                        _parser=new dmx_demuxerPS(1,&track,0);
257
 
                        if(!_parser->open(dup))
258
 
                        {
259
 
                                printf("Mpeg Parser : opening %s failed\n",_param->subname);
260
 
                                delete _parser;
261
 
                                _parser=NULL;
262
 
                
263
 
                         }
264
 
                         
265
 
                }
266
 
                ADM_dealloc(dup);
267
 
        }
268
 
        
269
 
        
270
 
        if(!_parser)
271
 
        {
272
 
                printf("opening of vobsub file failed\n");
273
 
        }
274
 
         else
275
 
        {       // Recompute sub duration
276
 
                uint32_t end;
277
 
                vobSubLine *cur,*next;
278
 
                // Assuming max displat time = MAX_DISPLAY_TIME
279
 
                for(uint32_t i=0;i<_vobSubInfo->nbLines-1;i++)
280
 
                {
281
 
                        if(i && !_vobSubInfo->lines[i].startTime)
282
 
                        {
283
 
                                _vobSubInfo->lines[i].startTime=0xf0000000;
284
 
                                _vobSubInfo->lines[i].stopTime=0xf0000001;
285
 
                                
286
 
                        }
287
 
                        else
288
 
                        {
289
 
                                cur=&_vobSubInfo->lines[i];
290
 
                                next=&_vobSubInfo->lines[i+1];
291
 
                        
292
 
                                end=cur->startTime+MAX_DISPLAY_TIME;
293
 
                                if(end>=next->startTime) end=next->startTime-1;
294
 
                                cur->stopTime=end;                                
295
 
                        }
296
 
                }
297
 
                _vobSubInfo->lines[_vobSubInfo->nbLines-1].stopTime=
298
 
                        MAX_DISPLAY_TIME+_vobSubInfo->lines[_vobSubInfo->nbLines-1].startTime;
299
 
                // Convert all the palette from RGB to YUV
300
 
                paletteYUV();
301
 
        }
302
 
      
303
 
        _x1=_y1=_x2=_y2=0;
304
 
        _data=new uint8_t [VS_MAXPACKET];
305
 
        _subSize=0;
306
 
        _subW=_subH=0;
307
 
        
308
 
        memset(&_original,0,sizeof(_original));
309
 
        _currentSub=NOSUB;
310
 
        _initialPts=0;
311
 
                
312
 
 
313
 
}
314
 
//*************************************************************
315
 
uint8_t ADMVideoVobSub::cleanup(void)
316
 
{
317
 
 
318
 
        if(_parser) delete _parser;
319
 
        _parser=NULL;
320
 
        
321
 
        if(_original)
322
 
          delete _original;
323
 
        _original=NULL;        
324
 
        
325
 
        if(_resampled)
326
 
          delete _resampled;
327
 
        _resampled=NULL;
328
 
        
329
 
        if(_chromaResampled)
330
 
          delete _chromaResampled;
331
 
        _chromaResampled=NULL;
332
 
        
333
 
        
334
 
        if(_data) delete [] _data;
335
 
        _data=NULL;
336
 
        
337
 
        if(_vobSubInfo) destroySubInfo( _vobSubInfo);
338
 
        _vobSubInfo=NULL;
339
 
        
340
 
 
341
 
}
342
 
//*************************************************************
343
 
ADMVideoVobSub::~ADMVideoVobSub()
344
 
{
345
 
        cleanup();
346
 
         if(_param)
347
 
        {
348
 
                if(_param->subname)  ADM_dealloc(_param->subname);
349
 
                DELETE(_param);
350
 
        }
351
 
        _param=NULL;
352
 
}
353
 
 
354
 
//*************************************************************
355
 
uint8_t ADMVideoVobSub::getCoupledConf( CONFcouple **couples)
356
 
{
357
 
                        ADM_assert(_param);
358
 
                        *couples=new CONFcouple(3);
359
 
 
360
 
#define CSET(x)  (*couples)->setCouple((char *)#x,(_param->x))
361
 
                        if(_param->subname)
362
 
                                CSET(subname);
363
 
                        else
364
 
                          (*couples)->setCouple("subname","none") ;
365
 
                        CSET(index);
366
 
                        CSET(subShift);
367
 
                        
368
 
 
369
 
                        return 1;
370
 
}
371
 
//*************************************************************
372
 
uint8_t ADMVideoVobSub::getFrameNumberNoAlloc(uint32_t frame,
373
 
                                uint32_t *len,
374
 
                                ADMImage *data,
375
 
                                uint32_t *flags)
376
 
{
377
 
 
378
 
uint64_t time;
379
 
uint32_t sub;
380
 
 
381
 
        ADM_assert(frame<_info.nb_frames);
382
 
        // read uncompressed frame
383
 
        if(!_in->getFrameNumberNoAlloc(frame, len,data,flags)) return 0;
384
 
 
385
 
        if(!_parser)        
386
 
        {
387
 
                //
388
 
                printf("No valid vobsub to process\n");
389
 
                
390
 
                return 1;
391
 
        
392
 
        }
393
 
        
394
 
        time=(frame+_info.orgFrame);
395
 
        time=(time*1000*1000)/_info.fps1000;
396
 
        
397
 
        sub=lookupSub(time);  
398
 
        // Should we re-use the current one ? 
399
 
        if(sub==NOSUB)
400
 
        {
401
 
                aprintf("No matching sub for time %llu frame%lu\n",time,frame);
402
 
                return 1;
403
 
        }
404
 
        // If it is a new sub, decode it...
405
 
        if(sub!=_currentSub )
406
 
        {                
407
 
                // _parser->_asyncJump2(0,_vobSubInfo->lines[sub].fileOffset);
408
 
                _parser->setPos(_vobSubInfo->lines[sub].fileOffset,0);
409
 
                 //_initialPts=_parser->getPTS();
410
 
                 handleSub(sub);
411
 
                _currentSub=sub;
412
 
                Palettte2Display(); // Create the bitmap
413
 
                // Time to resize the bitmap
414
 
                // First try : Do it bluntly
415
 
                
416
 
        }                
417
 
        
418
 
        // and if there is something to display, display it
419
 
        //
420
 
        vobSubBitmap *src;
421
 
        //src=_original;
422
 
        src=_resampled;
423
 
        
424
 
        if(src)          
425
 
        {
426
 
               
427
 
          aprintf("We have %lu %lu to merge\n",src->_width,src->_height);
428
 
                // Merge
429
 
                
430
 
                uint32_t stridein,strideout,len;
431
 
                uint8_t *in,*out,*mask,*in2;
432
 
                uint16_t old,nw,alp;
433
 
                uint32_t xx,yy;
434
 
                
435
 
                stridein=src->_width;
436
 
                strideout=_info.width;
437
 
                
438
 
                if(strideout>stridein)
439
 
                {
440
 
                        len=stridein;
441
 
                        xx=src->_width;
442
 
                }
443
 
                else
444
 
                {
445
 
                        xx=_info.width;
446
 
                        len=strideout;
447
 
                }
448
 
                if(src->_height>_info.height) yy=_info.height;
449
 
                        else                 yy=src->_height;           
450
 
                in=src->_bitmap;
451
 
                mask=src->_alphaMask;
452
 
               
453
 
                out=data->data+_info.width*src->placeTop;
454
 
                // auto center
455
 
                uint32_t center=_info.width-src->_width;
456
 
                out+=(center>>2)*2;
457
 
                
458
 
                for(uint32_t y=0;y<yy;y++)
459
 
                {
460
 
                  for(uint32_t x=0;x<xx;x++)
461
 
                        {
462
 
                               old=out[x];
463
 
                               nw=in[x];
464
 
                               alp=mask[x];
465
 
 
466
 
                                if(alp) 
467
 
                                {
468
 
                                  if(alp>7)  nw=old*(16-alp-1)+(alp+1)*nw;
469
 
                                        else nw=old*(16-alp)+(alp)*nw;
470
 
                                  out[x]=nw>>4;                                         
471
 
                                }
472
 
 
473
 
                               //out[x]=nw;
474
 
                        }
475
 
                        //memcpy(out,in,len);
476
 
                        out+=strideout;
477
 
                        in+=stridein;
478
 
                        mask+=stridein;
479
 
                }
480
 
                
481
 
                // Now do chroma u & chroma V
482
 
#define DOCHROMA                
483
 
#if defined(DOCHROMA)                
484
 
                uint32_t crosspage=(_info.width*_info.height)>>2;
485
 
                
486
 
                strideout=_info.width>>1;
487
 
                stridein=_chromaResampled->_width;
488
 
                
489
 
                out=data->data+_info.width*_info.height;
490
 
                out+=(src->placeTop>>1)*(_info.width>>1);
491
 
                mask=_chromaResampled->_alphaMask;
492
 
                // Center
493
 
                out+=(center>>2)*1;
494
 
                if(strideout>stridein) xx=stridein;
495
 
                else            xx=strideout;
496
 
                
497
 
                int16_t left=(_info.height>>1)-(_chromaResampled->_height+(_original->placeTop>>1));
498
 
                
499
 
                if(left<_chromaResampled->_height) yy=left;
500
 
                else yy=_chromaResampled->_height;
501
 
                
502
 
                for(uint32_t y=0;y<yy;y++)
503
 
                {
504
 
                   for(uint32_t x=0;x<xx;x++)
505
 
                   {
506
 
                        if(mask[x]>10)         
507
 
                        {
508
 
                          int16_t val;
509
 
                          val=out[x];
510
 
                          val-=128;
511
 
                         
512
 
                          
513
 
                          
514
 
                          nw=val*(16-alp);
515
 
                          
516
 
                          val/=4;
517
 
                          val=val+128;
518
 
                                
519
 
                          out[x]=val; 
520
 
                          out[crosspage+x]=val;
521
 
                        }                                                 
522
 
                   }
523
 
                   out+=strideout;
524
 
                   mask+=stridein;
525
 
                }
526
 
#endif                
527
 
        }
528
 
        return 1;
529
 
}
530
 
//*************************************************************************
531
 
//
532
 
//      Convert the original bitmap to a rescaled & repositionned one
533
 
//      that will be blended into the current picutr
534
 
//
535
 
//*************************************************************************
536
 
uint8_t ADMVideoVobSub::Palettte2Display( void )
537
 
{
538
 
        ADM_assert(_parser);
539
 
        ADM_assert(_vobSubInfo);
540
 
     
541
 
        // Then Process the RLE Datas
542
 
        // To get the _bitmap yuv data
543
 
        ADM_assert(_original);
544
 
        
545
 
        // Set correct color
546
 
        _original->buildYUV(_YUVPalette);
547
 
        
548
 
        // rebuild the scaled one
549
 
        // Compute the target size
550
 
        uint32_t fx,fy;
551
 
        uint32_t ox,oy;
552
 
        uint32_t sx,sy;
553
 
        /*
554
 
                Fx, fy : Final size of the image (i.e size of the current picture)
555
 
                ox,oy  : Original size of the image where the sub is coming from
556
 
                sx,sy  : Size of the  sub
557
 
        
558
 
                And we want the final size of the sub
559
 
                        + coordinates but that we will do later
560
 
        
561
 
        */
562
 
        
563
 
        fx=_info.width;
564
 
        fy=_info.height;
565
 
        
566
 
        ox=_vobSubInfo->width;
567
 
        oy=_vobSubInfo->height;
568
 
        
569
 
        sx=_subW;
570
 
        sy=_subH;
571
 
        
572
 
        // Search the 1st/last non null line
573
 
        uint32_t top=0,bottom=0;
574
 
 
575
 
        if(oy>_original->_height) oy=_original->_height-1;
576
 
 
577
 
        while(top<oy && !_original->isDirty(top)) top++;
578
 
        
579
 
        bottom=_original->_height-1;
580
 
        if(top==bottom)
581
 
        {
582
 
                printf("Empty sub ?");
583
 
                return 0;
584
 
        }
585
 
        
586
 
        while(bottom && !_original->isDirty(bottom)) bottom--;
587
 
        
588
 
        // If true it means we have 2 subs, one on top, one on bottom
589
 
        //
590
 
        if(bottom>(oy>>1) && top<(oy>>1) && (bottom-top>(oy>>1)))
591
 
        {
592
 
          // in that case, take only the lower one
593
 
          top=oy>>1;
594
 
          while(top<oy && !_original->isDirty(top)) top++;                    
595
 
        }
596
 
        //
597
 
        //  The useful part is between top & bottom lines
598
 
        //
599
 
        
600
 
        // Shrink factor
601
 
        // The shrink factor is the one used to shrink from the original video
602
 
        // to the resize video
603
 
        
604
 
        double scale,l;
605
 
        scale=fx;
606
 
        scale/=ox;
607
 
        printf("top %lu : bottom :%lu Scale :%f ox:%lu oy:%lu fx:%lu \n",top,bottom,scale,ox,oy,fx);
608
 
        
609
 
        // We rescale the sub by the same factor
610
 
        // Only the visible / useful part
611
 
        l=scale;
612
 
        l=l*sx;
613
 
        sx=(uint32_t )floor(l);
614
 
        
615
 
       
616
 
        l=scale;
617
 
        l=l*(bottom-top);
618
 
        sy=(uint32_t )floor(l);
619
 
        
620
 
 
621
 
        // And we resize that useful part of sub
622
 
        // to our final bitmap (resampled)
623
 
                
624
 
        _original->subResize(&_resampled,sx,sy,top, bottom-top);
625
 
                
626
 
        uint32_t tail;
627
 
        
628
 
        // Set the position of the sub so that it is ok
629
 
        
630
 
        tail=16+sy;
631
 
        
632
 
        if(tail>fy) tail=0;
633
 
        else
634
 
        {
635
 
            tail=fy-tail;           
636
 
        }
637
 
        
638
 
        _resampled->placeTop=tail;
639
 
        
640
 
        _resampled->subResize(&_chromaResampled,sx>>1,sy>>1,0,sy);
641
 
        return 1;
642
 
}
643
 
 
644
 
//
645
 
//      Return the index in the sub table of the sub matching the time
646
 
//
647
 
uint32_t ADMVideoVobSub::lookupSub(uint64_t time)
648
 
{
649
 
int64_t head,tail, cur;
650
 
int32_t i;
651
 
        cur=(int64_t)time;
652
 
        i=0;
653
 
        while(i<_vobSubInfo->nbLines-1)
654
 
        {
655
 
                head=(int64_t)_vobSubInfo->lines[i].startTime;
656
 
                tail=(int64_t) _vobSubInfo->lines[i].stopTime;
657
 
                head+=_param->subShift;
658
 
                tail+=_param->subShift;
659
 
                if(head<=cur &&tail>cur)
660
 
                {
661
 
                  aprintf("Matching for time %llu : sub %lu starting at :%lu (shift %lu)\n",
662
 
                                        time,i,_vobSubInfo->lines[i].startTime,_param->subShift);
663
 
                        return i; 
664
 
                }   
665
 
                if(head>cur) return NOSUB;                   
666
 
                i++;       
667
 
        }
668
 
        return NOSUB;
669
 
 
670
 
 
671
 
}
672
 
//EOF
673