~ubuntu-branches/ubuntu/feisty/avidemux/feisty

« back to all changes in this revision

Viewing changes to avidemux/ADM_video/ADM_vidVobSub.h

  • Committer: Bazaar Package Importer
  • Author(s): Christian Marillat
  • Date: 2005-05-25 13:02:29 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050525130229-jw94cav0yhmg7vjw
Tags: 1:2.0.40-0.0
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/***************************************************************************
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or modify  *
 
5
 *   it under the terms of the GNU General Public License as published by  *
 
6
 *   the Free Software Foundation; either version 2 of the License, or     *
 
7
 *   (at your option) any later version.                                   *
 
8
 *                                                                         *
 
9
 ***************************************************************************/
 
10
 
 
11
#ifndef _VOBSUB_V_
 
12
#define _VOBSUB_V_
 
13
 
 
14
#define VS_MAXPACKET 128*1024
 
15
 
 
16
#define NOSUB 0xffffffff
 
17
 
 
18
#define MAX_DISPLAY_TIME 3000 // 3s
 
19
 
 
20
//************************************
 
21
typedef struct vobSubParam
 
22
{
 
23
        char            *subname;
 
24
        uint32_t        index;
 
25
        int32_t         subShift;
 
26
}vobSubParam;
 
27
//************************************
 
28
class vobSubBitmap
 
29
{
 
30
  protected:
 
31
        uint8_t                         *_dirty;                   /// Dirty lines (non transparent)
 
32
  public:
 
33
        uint8_t                         isDirty(uint32_t line);
 
34
        uint8_t                         setDirty(uint32_t line);
 
35
 
 
36
        uint32_t                        _width,_height;
 
37
        uint32_t                        placeTop, placeHeight;     /// Position of the sub
 
38
      
 
39
        uint8_t                         *_bitmap;                  /// YUV image
 
40
        uint8_t                         *_alphaMask;               /// alpha mask 
 
41
        
 
42
 
 
43
                                        vobSubBitmap(uint32_t w, uint32_t h); 
 
44
                                        ~vobSubBitmap();
 
45
        void                            clear(void);
 
46
        
 
47
                                        /// Convert palette bitmap to yuv&mask bitmap
 
48
        uint8_t                         buildYUV( int16_t *palette ); 
 
49
                                        /// Generate the final bitmap (resized)
 
50
        uint8_t                         subResize(vobSubBitmap **tgt,uint32_t newx,uint32_t newy,
 
51
                                                uint32_t oldtop, uint32_t oldheight);
 
52
};
 
53
//************************************
 
54
class  ADMVideoVobSub:public AVDMGenericVideoStream
 
55
 {
 
56
 
 
57
 protected:
 
58
        virtual char                    *printConf(void);
 
59
        uint8_t                         readbyte(void);         /// Read a byte from buffer
 
60
        uint16_t                        readword(void);         /// Read a 16 bits word from buffer
 
61
        uint8_t                         forward(uint32_t v);    /// Read a 16 bits word from buffer
 
62
        uint8_t                         decodeRLE(uint32_t off,uint32_t start,uint32_t end);
 
63
        uint8_t                         setup(void);            /// Rebuild internal info
 
64
        uint8_t                         cleanup(void);          /// Destroy all internal info
 
65
        uint8_t                         paletteYUV( void );     /// Convert RGB Pallette to yuv
 
66
        uint8_t                         Palettte2Display( void ); /// Convert the RLE to YUV bitmap
 
67
        uint8_t                         handleSub( uint32_t idx );/// Decode a sub packet
 
68
        uint32_t                        lookupSub(uint64_t time);/// Return sub index corresponding to time
 
69
        
 
70
        ADM_mpegDemuxerProgramStream    *_parser;        
 
71
        uint8_t                         *_data;                 /// Data for packet
 
72
        VobSubInfo                      *_vobSubInfo;           /// Info of the index file
 
73
        vobSubParam                     *_param;
 
74
        vobSubBitmap                    *_original;              /// True size (..) depacked vobsub
 
75
        vobSubBitmap                    *_resampled;            /// Final one; to be blended in picture
 
76
        vobSubBitmap                    *_chromaResampled;      /// Same as above but shinked by 2
 
77
        uint32_t                        _x1,_y1,_x2,_y2;        /// sub boxing
 
78
        uint32_t                        _subW,_subH;
 
79
        uint8_t                         _displaying;            ///  Is display active
 
80
        uint32_t                        _curOffset;
 
81
        uint32_t                        _subSize;
 
82
        uint32_t                        _dataSize;              /// Size of the data chunk
 
83
        
 
84
        uint8_t                         _colors[4];             /// Colors palette
 
85
        uint8_t                         _alpha[4];              /// Colors alpha
 
86
        int16_t                         _YUVPalette[16];        /// Luma only
 
87
        uint32_t                        _currentSub;            ///
 
88
        uint32_t                        _initialPts;
 
89
 public:
 
90
    /* This 3 functions are used by OCR */
 
91
                        ADMVideoVobSub(  char *fileidx,uint32_t idx);
 
92
              vobSubBitmap *getBitmap(uint32_t nb,uint32_t *start, uint32_t *end,uint32_t *first,uint32_t *last);
 
93
              uint32_t     getNbImage( void);
 
94
    /* /ocr */ 
 
95
    
 
96
                        ADMVideoVobSub(  AVDMGenericVideoStream *in,CONFcouple *setup);
 
97
                        ~ADMVideoVobSub();
 
98
        virtual uint8_t getFrameNumberNoAlloc(uint32_t frame, uint32_t *len,
 
99
                                                ADMImage *data,uint32_t *flags);
 
100
        virtual uint8_t getCoupledConf( CONFcouple **couples)           ;
 
101
        virtual uint8_t configure( AVDMGenericVideoStream *instream);
 
102
                                                        
 
103
};
 
104
#endif