~ubuntu-branches/ubuntu/karmic/pygame/karmic

« back to all changes in this revision

Viewing changes to src/ffmovie.h

  • Committer: Bazaar Package Importer
  • Author(s): Joe Wreschnig
  • Date: 2005-09-15 15:10:45 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050915151045-6j7tiaorbf42xqia
Tags: 1.7.1release-1
* New upstream release.
* Remove 64-bit patch from 1.6-0.2, merged upstream.
* Remove SMPEG detection patch from 1.4-1, no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <SDL.h>
 
2
#include <SDL_thread.h>
 
3
#include <ffmpeg/avformat.h>
 
4
 
 
5
 
 
6
 
 
7
#define MAX_SOURCENAME 1024
 
8
#define MAX_AUDIOQ_SIZE (5 * 16 * 1024)
 
9
 
 
10
/* SDL audio buffer size, in samples. Should be small to have precise
 
11
   A/V sync as SDL does not have hardware buffer fullness info. */
 
12
#define SDL_AUDIO_BUFFER_SIZE 1024
 
13
 
 
14
/* no AV sync correction is done if below the AV sync threshold */
 
15
#define AV_SYNC_THRESHOLD 0.08
 
16
/* no AV correction is done if too big error */
 
17
#define AV_NOSYNC_THRESHOLD 10.0
 
18
 
 
19
/* maximum audio speed change to get correct sync */
 
20
#define SAMPLE_CORRECTION_PERCENT_MAX 10
 
21
 
 
22
/* we use about AUDIO_DIFF_AVG_NB A-V differences to make the average */
 
23
#define AUDIO_DIFF_AVG_NB   20
 
24
 
 
25
/* NOTE: the size must be big enough to compensate the hardware audio buffersize size */
 
26
#define SAMPLE_ARRAY_SIZE (2*65536)
 
27
 
 
28
 
 
29
 
 
30
 
 
31
 
 
32
typedef struct PacketQueue {
 
33
    AVPacketList *first_pkt, *last_pkt;
 
34
    int nb_packets;
 
35
    int size;
 
36
    int abort_request;
 
37
    SDL_mutex *mutex;
 
38
    SDL_cond *cond;
 
39
} PacketQueue;
 
40
 
 
41
 
 
42
 
 
43
typedef struct FFMovie {
 
44
    SDL_Thread *decode_thread;
 
45
    int abort_request;
 
46
    int paused;
 
47
    AVFormatContext *context;
 
48
 
 
49
    double external_clock; /* external clock base */
 
50
    int64_t external_clock_time;
 
51
 
 
52
    double audio_clock;
 
53
    double audio_diff_cum; /* used for AV difference average computation */
 
54
    double audio_diff_avg_coef;
 
55
    double audio_diff_threshold;
 
56
    int audio_diff_avg_count;
 
57
    AVStream *audio_st;
 
58
    PacketQueue audioq;
 
59
    int audio_hw_buf_size;
 
60
    /* samples output by the codec. we reserve more space for avsync compensation */
 
61
    uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2];
 
62
    int audio_buf_size; /* in bytes */
 
63
    int audio_buf_index; /* in bytes */
 
64
    AVPacket audio_pkt;
 
65
    uint8_t *audio_pkt_data;
 
66
    int audio_pkt_size;
 
67
    int64_t audio_pkt_ipts;
 
68
    int audio_volume; /*must self implement*/
 
69
 
 
70
    int16_t sample_array[SAMPLE_ARRAY_SIZE];
 
71
    int sample_array_index;
 
72
 
 
73
    int frame_count;
 
74
    double frame_timer;
 
75
    double frame_last_pts;
 
76
    double frame_last_delay;
 
77
    double frame_delay; /*display time of each frame, based on fps*/
 
78
    double video_clock; /*seconds of video frame decoded*/
 
79
    AVStream *video_st;
 
80
    int64_t vidpkt_timestamp;
 
81
    int vidpkt_start;
 
82
    double video_last_P_pts; /* pts of the last P picture (needed if B
 
83
                                frames are present) */
 
84
    double video_current_pts; /* current displayed pts (different from
 
85
                                 video_clock if frame fifos are used) */
 
86
 
 
87
    SDL_mutex *dest_mutex;
 
88
    double dest_showtime; /*when to next show the dest_overlay*/
 
89
    SDL_Overlay *dest_overlay;
 
90
    SDL_Surface *dest_surface;
 
91
    SDL_Rect dest_rect;
 
92
 
 
93
    double time_offset; /*track paused time*/
 
94
    
 
95
    int audio_disable;
 
96
    
 
97
    const char *sourcename;
 
98
} FFMovie;
 
99
 
 
100
 
 
101
 
 
102
 
 
103
FFMovie *ffmovie_open(const char *filename);
 
104
FFMovie *ffmovie_reopen(FFMovie *movie);
 
105
void ffmovie_close(FFMovie *movie);
 
106
void ffmovie_play(FFMovie *movie);
 
107
void ffmovie_stop(FFMovie *movie);
 
108
void ffmovie_pause(FFMovie *movie);
 
109
void ffmovie_setvolume(FFMovie *movie, int volume);
 
110
void ffmovie_setdisplay(FFMovie *movie, SDL_Surface *dest, SDL_Rect *rect);
 
111
void ffmovie_abortall(void);
 
112
 
 
113