Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_05 / synfig-core / src / modules / mod_libavcodec / libavformat / dvcore.h
1 /* 
2  * DV format muxer/demuxer
3  * Copyright (c) 2003 Roman Shaposhnik
4  *
5  * Many thanks to Dan Dennedy <dan@dennedy.org> for providing wealth
6  * of DV technical info.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22 #include <time.h>
23 #include "avformat.h"
24
25 /* 
26  * DVprofile is used to express the differences between various 
27  * DV flavors. For now it's primarily used for differentiating
28  * 525/60 and 625/50, but the plans are to use it for various
29  * DV specs as well (e.g. SMPTE314M vs. IEC 61834).
30  */
31 typedef struct DVprofile {
32     int            dsf;                  /* value of the dsf in the DV header */
33     int            frame_size;           /* total size of one frame in bytes */
34     int            difseg_size;          /* number of DIF segments */
35     int            frame_rate;      
36     int            frame_rate_base;
37     int            ltc_divisor;          /* FPS from the LTS standpoint */
38     int            height;               /* picture height in pixels */
39     uint16_t       *video_place;         /* positions of all DV macro blocks */
40     
41     int            audio_stride;         /* size of audio_shuffle table */
42     int            audio_min_samples[3]; /* min ammount of audio samples */
43                                          /* for 48Khz, 44.1Khz and 32Khz */
44     int            audio_samples_dist[5];/* how many samples are supposed to be */
45                                          /* in each frame in a 5 frames window */
46     const uint16_t (*audio_shuffle)[9];  /* PCM shuffling table */
47 } DVprofile;
48
49 typedef struct DVMuxContext {
50     const DVprofile*  sys;    /* Current DV profile. E.g.: 525/60, 625/50 */
51     uint8_t     frame_buf[144000]; /* frame under contruction */
52     FifoBuffer  audio_data;   /* Fifo for storing excessive amounts of PCM */
53     int         frames;       /* Number of a current frame */
54     time_t      start_time;   /* Start time of recording */
55     uint8_t     aspect;       /* Aspect ID 0 - 4:3, 7 - 16:9 */
56     int         ast, vst;     /* Audio and Video stream indecies */
57     int         has_audio;    /* frame under contruction has audio */
58     int         has_video;    /* frame under contruction has video */
59 } DVMuxContext;
60
61 void dv_format_frame(DVMuxContext *, uint8_t*);
62 void dv_inject_audio(DVMuxContext *, const uint8_t*, uint8_t*);
63 void dv_inject_video(DVMuxContext *, const uint8_t*, uint8_t*);
64
65 int  dv_extract_audio(uint8_t*, uint8_t*, AVCodecContext*);
66
67 int  dv_audio_frame_size(const DVprofile*, int);
68
69 void dv_assemble_frame(DVMuxContext *c, const uint8_t*, const uint8_t*, int);
70 int  dv_core_init(DVMuxContext *, AVStream*[]);
71 void dv_core_delete(DVMuxContext *);
72
73 const DVprofile* dv_frame_profile(uint8_t*);