00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef QTFFPLAYINCLUDES_H
00022 #define QTFFPLAYINCLUDES_H
00023
00024 #define HAVE_AV_CONFIG_H
00025 #include "avformat.h"
00026
00027 #include "cmdutils.h"
00028
00029 #include <SDL.h>
00030 #include <SDL_thread.h>
00031
00032 #ifdef CONFIG_WIN32
00033 #undef main
00034 #endif
00035
00036 #ifdef CONFIG_OS2
00037 #define INCL_DOS
00038 #include <os2.h>
00039 #include <stdio.h>
00040
00041 void MorphToPM()
00042 {
00043 PPIB pib;
00044 PTIB tib;
00045
00046 DosGetInfoBlocks(&tib, &pib);
00047
00048
00049 if (pib->pib_ultype==2) pib->pib_ultype = 3;
00050 }
00051 #endif
00052
00053 #if defined(__linux__)
00054 #define HAVE_X11
00055 #endif
00056
00057 #ifdef HAVE_X11
00058 #include <X11/Xlib.h>
00059 #endif
00060
00061
00062
00063 #define MAX_VIDEOQ_SIZE (5 * 256 * 1024)
00064 #define MAX_AUDIOQ_SIZE (5 * 16 * 1024)
00065 #define MAX_SUBTITLEQ_SIZE (5 * 16 * 1024)
00066
00067
00068
00069 #define SDL_AUDIO_BUFFER_SIZE 1024
00070
00071
00072 #define AV_SYNC_THRESHOLD 0.01
00073
00074 #define AV_NOSYNC_THRESHOLD 10.0
00075
00076
00077 #define SAMPLE_CORRECTION_PERCENT_MAX 10
00078
00079
00080 #define AUDIO_DIFF_AVG_NB 20
00081
00082
00083 #define SAMPLE_ARRAY_SIZE (2*65536)
00084
00085 typedef struct PacketQueue {
00086 AVPacketList *first_pkt, *last_pkt;
00087 int nb_packets;
00088 int size;
00089 int abort_request;
00090 SDL_mutex *mutex;
00091 SDL_cond *cond;
00092 } PacketQueue;
00093
00094 #define VIDEO_PICTURE_QUEUE_SIZE 1
00095 #define SUBPICTURE_QUEUE_SIZE 4
00096
00097 typedef struct VideoPicture {
00098 double pts;
00099 SDL_Overlay *bmp;
00100 int width, height;
00101 int allocated;
00102 } VideoPicture;
00103
00104 typedef struct SubPicture {
00105 double pts;
00106 AVSubtitle sub;
00107 } SubPicture;
00108
00109 enum {
00110 AV_SYNC_AUDIO_MASTER,
00111 AV_SYNC_VIDEO_MASTER,
00112 AV_SYNC_EXTERNAL_CLOCK,
00113 };
00114
00115 typedef struct VideoState {
00116 SDL_Thread *parse_tid;
00117 SDL_Thread *video_tid;
00118 AVInputFormat *iformat;
00119 int no_background;
00120 int abort_request;
00121 int paused;
00122 int last_paused;
00123 int seek_req;
00124 int seek_flags;
00125 int64_t seek_pos;
00126 AVFormatContext *ic;
00127 int dtg_active_format;
00128
00129 int audio_stream;
00130
00131 int av_sync_type;
00132 double external_clock;
00133 int64_t external_clock_time;
00134
00135 double audio_clock;
00136 double audio_diff_cum;
00137 double audio_diff_avg_coef;
00138 double audio_diff_threshold;
00139 int audio_diff_avg_count;
00140 AVStream *audio_st;
00141 PacketQueue audioq;
00142 int audio_hw_buf_size;
00143
00144
00145 uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2];
00146 unsigned int audio_buf_size;
00147 int audio_buf_index;
00148 AVPacket audio_pkt;
00149 uint8_t *audio_pkt_data;
00150 int audio_pkt_size;
00151
00152 int show_audio;
00153 int16_t sample_array[SAMPLE_ARRAY_SIZE];
00154 int sample_array_index;
00155 int last_i_start;
00156
00157 SDL_Thread *subtitle_tid;
00158 int subtitle_stream;
00159 int subtitle_stream_changed;
00160 AVStream *subtitle_st;
00161 PacketQueue subtitleq;
00162 SubPicture subpq[SUBPICTURE_QUEUE_SIZE];
00163 int subpq_size, subpq_rindex, subpq_windex;
00164 SDL_mutex *subpq_mutex;
00165 SDL_cond *subpq_cond;
00166
00167 double frame_timer;
00168 double frame_last_pts;
00169 double frame_last_delay;
00170 double video_clock;
00171 int video_stream;
00172 AVStream *video_st;
00173 PacketQueue videoq;
00174 double video_current_pts;
00175 int64_t video_current_pts_time;
00176 VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];
00177 int pictq_size, pictq_rindex, pictq_windex;
00178 SDL_mutex *pictq_mutex;
00179 SDL_cond *pictq_cond;
00180
00181 SDL_mutex *video_decoder_mutex;
00182 SDL_mutex *audio_decoder_mutex;
00183 SDL_mutex *subtitle_decoder_mutex;
00184
00185
00186 char filename[1024];
00187 int width, height, xleft, ytop;
00188 } VideoState;
00189
00190
00191 static AVInputFormat *file_iformat;
00192 static AVImageFormat *image_format;
00193
00194 static int fs_screen_width;
00195 static int fs_screen_height;
00196 static int screen_width = 640;
00197 static int screen_height = 480;
00198 static int audio_disable;
00199 static int video_disable;
00200 static int display_disable;
00201 static int show_status;
00202 static int av_sync_type = AV_SYNC_AUDIO_MASTER;
00203 static int64_t start_time = AV_NOPTS_VALUE;
00204 static int debug = 0;
00205 static int debug_mv = 0;
00206 static int step = 0;
00207 static int thread_count = 1;
00208 static int workaround_bugs = 1;
00209 static int fast = 0;
00210 static int genpts = 0;
00211 static int lowres = 0;
00212 static int idct = FF_IDCT_AUTO;
00213 static enum AVDiscard skip_frame= AVDISCARD_DEFAULT;
00214 static enum AVDiscard skip_idct= AVDISCARD_DEFAULT;
00215 static enum AVDiscard skip_loop_filter= AVDISCARD_DEFAULT;
00216 static int error_resilience = FF_ER_CAREFUL;
00217 static int error_concealment = 3;
00218
00219
00220 static int is_full_screen;
00221 static VideoState *cur_stream;
00222 static int64_t audio_callback_time;
00223
00224 #define FF_ALLOC_EVENT (SDL_USEREVENT)
00225 #define FF_REFRESH_EVENT (SDL_USEREVENT + 1)
00226 #define FF_QUIT_EVENT (SDL_USEREVENT + 2)
00227
00228
00229 #define SCALEBITS 10
00230 #define ONE_HALF (1 << (SCALEBITS - 1))
00231 #define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
00232
00233 #define RGB_TO_Y_CCIR(r, g, b) \
00234 ((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
00235 FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
00236
00237 #define RGB_TO_U_CCIR(r1, g1, b1, shift)\
00238 (((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \
00239 FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
00240
00241 #define RGB_TO_V_CCIR(r1, g1, b1, shift)\
00242 (((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
00243 FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
00244
00245 #define ALPHA_BLEND(a, oldp, newp, s)\
00246 ((((oldp << s) * (255 - (a))) + (newp * (a))) / (255 << s))
00247
00248 #define RGBA_IN(r, g, b, a, s)\
00249 {\
00250 unsigned int v = ((const uint32_t *)(s))[0];\
00251 a = (v >> 24) & 0xff;\
00252 r = (v >> 16) & 0xff;\
00253 g = (v >> 8) & 0xff;\
00254 b = v & 0xff;\
00255 }
00256
00257 #define YUVA_IN(y, u, v, a, s, pal)\
00258 {\
00259 unsigned int val = ((const uint32_t *)(pal))[*(const uint8_t*)s];\
00260 a = (val >> 24) & 0xff;\
00261 y = (val >> 16) & 0xff;\
00262 u = (val >> 8) & 0xff;\
00263 v = val & 0xff;\
00264 }
00265
00266 #define YUVA_OUT(d, y, u, v, a)\
00267 {\
00268 ((uint32_t *)(d))[0] = (a << 24) | (y << 16) | (u << 8) | v;\
00269 }
00270
00271
00272 #define BPP 1
00273
00274
00275
00276 static VideoState *global_video_state;
00277
00278 #endif