aboutsummaryrefslogtreecommitdiffhomepage
path: root/libmpdemux
diff options
context:
space:
mode:
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/aviheader.c2
-rw-r--r--libmpdemux/demux_avi.c15
-rw-r--r--libmpdemux/demux_avs.c2
-rw-r--r--libmpdemux/demux_lavf.c7
-rw-r--r--libmpdemux/demux_mkv.c43
-rw-r--r--libmpdemux/demux_mov.c5
-rw-r--r--libmpdemux/demux_mpg.c6
-rw-r--r--libmpdemux/demux_nemesi.c2
-rw-r--r--libmpdemux/demux_ogg.c11
-rw-r--r--libmpdemux/demux_pva.c2
-rw-r--r--libmpdemux/demux_rtp.cpp10
-rw-r--r--libmpdemux/demuxer.c89
-rw-r--r--libmpdemux/demuxer.h57
-rw-r--r--libmpdemux/mp3_hdr.c3
-rw-r--r--libmpdemux/parse_mp4.c2
-rw-r--r--libmpdemux/stheader.h31
16 files changed, 152 insertions, 135 deletions
diff --git a/libmpdemux/aviheader.c b/libmpdemux/aviheader.c
index 85a84e8ca3..fa7f27c4fc 100644
--- a/libmpdemux/aviheader.c
+++ b/libmpdemux/aviheader.c
@@ -42,7 +42,7 @@ static int odml_get_vstream_id(int id, unsigned char res[])
return 0;
}
-int avi_idx_cmp(const void *elem1,const void *elem2) {
+static int avi_idx_cmp(const void *elem1,const void *elem2) {
register off_t a = AVI_IDX_OFFSET((AVIINDEXENTRY *)elem1);
register off_t b = AVI_IDX_OFFSET((AVIINDEXENTRY *)elem2);
return (a > b) - (b > a);
diff --git a/libmpdemux/demux_avi.c b/libmpdemux/demux_avi.c
index fa1fc91e48..9695fcb556 100644
--- a/libmpdemux/demux_avi.c
+++ b/libmpdemux/demux_avi.c
@@ -24,7 +24,9 @@ extern const demuxer_desc_t demuxer_desc_avi_nini;
int pts_from_bps=1;
// Select ds from ID
-demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id){
+static demux_stream_t* demux_avi_select_stream(demuxer_t *demux,
+ unsigned int id)
+{
int stream_id=avi_stream_id(id);
@@ -277,7 +279,7 @@ do{
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t* ds){
+static int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t* ds){
avi_priv_t *priv=demux->priv;
unsigned int id=0;
unsigned int len;
@@ -341,7 +343,7 @@ do{
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t* ds){
+static int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t* ds){
avi_priv_t *priv=demux->priv;
unsigned int id=0;
unsigned int len;
@@ -572,7 +574,7 @@ static demuxer_t* demux_open_avi(demuxer_t* demuxer){
}
-void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
+static void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
avi_priv_t *priv=demuxer->priv;
demux_stream_t *d_audio=demuxer->audio;
demux_stream_t *d_video=demuxer->video;
@@ -745,7 +747,7 @@ void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int
}
-void demux_close_avi(demuxer_t *demuxer) {
+static void demux_close_avi(demuxer_t *demuxer) {
avi_priv_t* priv=demuxer->priv;
if(!priv)
@@ -837,6 +839,7 @@ static int avi_check_file(demuxer_t *demuxer)
static demuxer_t* demux_open_hack_avi(demuxer_t *demuxer)
{
+ struct MPOpts *opts = demuxer->opts;
sh_audio_t* sh_a;
demuxer = demux_open_avi(demuxer);
@@ -851,7 +854,7 @@ static demuxer_t* demux_open_hack_avi(demuxer_t *demuxer)
stream_t* s;
demuxer_t *od;
s = new_ds_stream(demuxer->audio);
- od = new_demuxer(s,DEMUXER_TYPE_OGG,-1,-2,-2,NULL);
+ od = new_demuxer(opts, s,DEMUXER_TYPE_OGG,-1,-2,-2,NULL);
if(!demux_ogg_open(od)) {
mp_msg( MSGT_DEMUXER,MSGL_ERR,MSGTR_ErrorOpeningOGGDemuxer);
free_stream(s);
diff --git a/libmpdemux/demux_avs.c b/libmpdemux/demux_avs.c
index 8d2ac82046..444e06c90c 100644
--- a/libmpdemux/demux_avs.c
+++ b/libmpdemux/demux_avs.c
@@ -85,7 +85,7 @@ typedef struct tagAVS
imp_avs_get_audio avs_get_audio;
} AVS_T;
-AVS_T *initAVS(const char *filename)
+static AVS_T *initAVS(const char *filename)
{
AVS_T *AVS = malloc (sizeof(AVS_T));
AVS_Value arg0 = avs_new_value_string(filename);
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index 9749054a03..047315e74c 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -24,6 +24,7 @@
#include <limits.h>
#include "config.h"
+#include "options.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "av_opts.h"
@@ -43,9 +44,6 @@
#define PROBE_BUF_SIZE 2048
-extern char *audio_lang;
-extern char *dvdsub_lang;
-extern int dvdsub_id;
static unsigned int opt_probesize = 0;
static unsigned int opt_analyzeduration = 0;
static char *opt_format;
@@ -418,6 +416,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
}
static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
+ struct MPOpts *opts = demuxer->opts;
AVFormatContext *avfc;
AVFormatParameters ap;
const AVOption *opt;
@@ -433,7 +432,7 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
if (opt_cryptokey)
parse_cryptokey(avfc, opt_cryptokey);
- if (user_correct_pts != 0)
+ if (opts->user_correct_pts != 0)
avfc->flags |= AVFMT_FLAG_GENPTS;
if (index_mode == 0)
avfc->flags |= AVFMT_FLAG_IGNIDX;
diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c
index 6d4429377c..76a3874723 100644
--- a/libmpdemux/demux_mkv.c
+++ b/libmpdemux/demux_mkv.c
@@ -13,6 +13,7 @@
#include <ctype.h>
#include <inttypes.h>
+#include "options.h"
#include "stream/stream.h"
#include "demuxer.h"
#include "stheader.h"
@@ -55,13 +56,12 @@ static const unsigned char sipr_swaps[38][2]={
#define ATRC_FLAVORS 8
#define COOK_FLAVORS 34
static const int sipr_fl2bps[SIPR_FLAVORS] = {813, 1062, 625, 2000};
-static const int atrc_fl2bps[ATRC_FLAVORS] =
- {8269, 11714, 13092, 16538, 18260, 22050, 33075, 44100};
-static const int cook_fl2bps[COOK_FLAVORS] =
- { 1000, 1378, 2024, 2584, 4005, 5513, 8010, 4005, 750, 2498,
- 4048, 5513, 8010, 11973, 8010, 2584, 4005, 2067, 2584, 2584,
- 4005, 4005, 5513, 5513, 8010, 12059, 1550, 8010, 12059, 5513,
- 12016, 16408, 22911, 33506};
+static const int atrc_fl2bps[ATRC_FLAVORS] = {8269, 11714, 13092, 16538, 18260, 22050, 33075, 44100};
+static const int cook_fl2bps[COOK_FLAVORS] = {
+ 1000, 1378, 2024, 2584, 4005, 5513, 8010, 4005, 750, 2498,
+ 4048, 5513, 8010, 11973, 8010, 2584, 4005, 2067, 2584, 2584,
+ 4005, 4005, 5513, 5513, 8010, 12059, 1550, 8010, 12059, 5513,
+ 12016, 16408, 22911, 33506};
typedef struct
{
@@ -93,7 +93,7 @@ typedef struct mkv_track
int default_track;
- void *private_data;
+ unsigned char *private_data;
unsigned int private_size;
/* stuff for realmedia */
@@ -182,20 +182,16 @@ typedef struct mkv_demuxer
#define RAPROPERTIES4_SIZE 56
#define RAPROPERTIES5_SIZE 70
-/* for e.g. "-slang ger" */
-extern char *dvdsub_lang;
-extern char *audio_lang;
-extern int dvdsub_id;
-
/**
* \brief ensures there is space for at least one additional element
* \param array array to grow
* \param nelem current number of elements in array
* \param elsize size of one array element
*/
-static void grow_array(void **array, int nelem, size_t elsize) {
+static void *grow_array(void *array, int nelem, size_t elsize) {
if (!(nelem & 31))
- *array = realloc(*array, (nelem + 32) * elsize);
+ array = realloc(array, (nelem + 32) * elsize);
+ return array;
}
static mkv_track_t *
@@ -220,8 +216,9 @@ add_cluster_position (mkv_demuxer_t *mkv_d, uint64_t position)
if (mkv_d->cluster_positions[i] == position)
return;
- grow_array(&mkv_d->cluster_positions, mkv_d->num_cluster_pos,
- sizeof(uint64_t));
+ mkv_d->cluster_positions = grow_array(mkv_d->cluster_positions,
+ mkv_d->num_cluster_pos,
+ sizeof(uint64_t));
mkv_d->cluster_positions[mkv_d->num_cluster_pos++] = position;
}
@@ -1064,7 +1061,8 @@ demux_mkv_read_cues (demuxer_t *demuxer)
if (time != EBML_UINT_INVALID && track != EBML_UINT_INVALID
&& pos != EBML_UINT_INVALID)
{
- grow_array(&mkv_d->indexes, mkv_d->num_indexes, sizeof(mkv_index_t));
+ mkv_d->indexes = grow_array(mkv_d->indexes, mkv_d->num_indexes,
+ sizeof(mkv_index_t));
mkv_d->indexes[mkv_d->num_indexes].tnum = track;
mkv_d->indexes[mkv_d->num_indexes].timecode = time;
mkv_d->indexes[mkv_d->num_indexes].filepos =mkv_d->segment_start+pos;
@@ -1514,6 +1512,7 @@ static const videocodec_info_t vinfo[] = {
static int
demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track, int vid)
{
+ struct MPOpts *opts = demuxer->opts;
BITMAPINFOHEADER *bih;
void *ImageDesc = NULL;
sh_video_t *sh_v;
@@ -1624,7 +1623,7 @@ demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track, int vid)
bih = realloc (bih, bih->biSize);
memcpy (bih + 1, track->private_data, track->private_size);
}
- track->reorder_timecodes = user_correct_pts == 0;
+ track->reorder_timecodes = opts->user_correct_pts == 0;
if (!vi->id) {
mp_msg (MSGT_DEMUX,MSGL_WARN, MSGTR_MPDEMUX_MKV_UnknownCodecID,
track->codec_id, track->tnum);
@@ -1950,13 +1949,13 @@ demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid)
if (track->a_formattag == mmioFOURCC('f', 'L', 'a', 'C'))
{
- ptr = (unsigned char *)track->private_data;
+ ptr = track->private_data;
size = track->private_size;
}
else
{
sh_a->format = mmioFOURCC('f', 'L', 'a', 'C');
- ptr = (unsigned char *) track->private_data
+ ptr = track->private_data
+ sizeof (WAVEFORMATEX);
size = track->private_size - sizeof (WAVEFORMATEX);
}
@@ -2026,8 +2025,6 @@ demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track, int sid)
return 0;
}
-static void demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags);
-
static int
demux_mkv_open (demuxer_t *demuxer)
{
diff --git a/libmpdemux/demux_mov.c b/libmpdemux/demux_mov.c
index 8217c47a95..fb271e1e49 100644
--- a/libmpdemux/demux_mov.c
+++ b/libmpdemux/demux_mov.c
@@ -144,7 +144,7 @@ typedef struct {
void* desc; // image/sound/etc description (pointer to ImageDescription etc)
} mov_track_t;
-void mov_build_index(mov_track_t* trak,int timescale){
+static void mov_build_index(mov_track_t* trak,int timescale){
int i,j,s;
int last=trak->chunks_size;
unsigned int pts=0;
@@ -1917,6 +1917,7 @@ static int lschunks_intrak(demuxer_t* demuxer, int level, unsigned int id,
}
static demuxer_t* mov_read_header(demuxer_t* demuxer){
+ struct MPOpts *opts = demuxer->opts;
mov_priv_t* priv=demuxer->priv;
int t_no;
int best_a_id=-1, best_a_len=0;
@@ -1992,7 +1993,7 @@ static demuxer_t* mov_read_header(demuxer_t* demuxer){
demuxer->video->id = t_no;
s = new_ds_stream(demuxer->video);
- od = demux_open(s, DEMUXER_TYPE_MPEG_PS, -1, -1, -1, NULL);
+ od = demux_open(opts, s, DEMUXER_TYPE_MPEG_PS, -1, -1, -1, NULL);
if(od) return new_demuxers_demuxer(od, od, od);
demuxer->video->id = -2; //new linked demuxer couldn't be allocated
break;
diff --git a/libmpdemux/demux_mpg.c b/libmpdemux/demux_mpg.c
index 8edb6e7a1e..489821f878 100644
--- a/libmpdemux/demux_mpg.c
+++ b/libmpdemux/demux_mpg.c
@@ -794,7 +794,7 @@ static int demux_mpg_gxf_fill_buffer(demuxer_t *demux, demux_stream_t *ds) {
return 1;
}
-int demux_mpg_fill_buffer(demuxer_t *demux, demux_stream_t *ds){
+static int demux_mpg_fill_buffer(demuxer_t *demux, demux_stream_t *ds){
unsigned int head=0;
int skipped=0;
int max_packs=256; // 512kbyte
@@ -881,7 +881,7 @@ do{
void skip_audio_frame(sh_audio_t *sh_audio);
-void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,float audio_delay, int flags){
+static void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,float audio_delay, int flags){
demux_stream_t *d_audio=demuxer->audio;
demux_stream_t *d_video=demuxer->video;
sh_audio_t *sh_audio=d_audio->sh;
@@ -987,7 +987,7 @@ void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,float audio_delay, in
}
}
-int demux_mpg_control(demuxer_t *demuxer,int cmd, void *arg){
+static int demux_mpg_control(demuxer_t *demuxer,int cmd, void *arg){
mpg_demuxer_t *mpg_d=(mpg_demuxer_t*)demuxer->priv;
switch(cmd) {
diff --git a/libmpdemux/demux_nemesi.c b/libmpdemux/demux_nemesi.c
index c1ed7f1089..704f14cf81 100644
--- a/libmpdemux/demux_nemesi.c
+++ b/libmpdemux/demux_nemesi.c
@@ -455,7 +455,7 @@ static void demux_seek_rtp(demuxer_t *demuxer, float rel_seek_secs,
mp_msg(MSGT_DEMUX, MSGL_ERR, "Unsupported seek type\n");
}
-static int demux_rtp_control(struct demuxer_st *demuxer, int cmd, void *arg)
+static int demux_rtp_control(struct demuxer *demuxer, int cmd, void *arg)
{
Nemesi_DemuxerStreamData * ndsd = demuxer->priv;
rtsp_ctrl * ctl = ndsd->rtsp;
diff --git a/libmpdemux/demux_ogg.c b/libmpdemux/demux_ogg.c
index 2561714517..013bff5a76 100644
--- a/libmpdemux/demux_ogg.c
+++ b/libmpdemux/demux_ogg.c
@@ -8,6 +8,7 @@
#include <math.h>
#include <inttypes.h>
+#include "options.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "stream/stream.h"
@@ -146,7 +147,6 @@ typedef struct ogg_demuxer {
#define PACKET_IS_SYNCPOINT 0x08
extern char *dvdsub_lang, *audio_lang;
-extern int dvdsub_id;
//-------- subtitle support - should be moved to decoder layer, and queue
// - subtitles up in demuxer buffer...
@@ -158,7 +158,7 @@ extern int dvdsub_id;
static subtitle ogg_sub;
//FILE* subout;
-void demux_ogg_add_sub (ogg_stream_t* os,ogg_packet* pack) {
+static void demux_ogg_add_sub (ogg_stream_t* os,ogg_packet* pack) {
int lcv;
char *packet = pack->packet;
@@ -395,7 +395,7 @@ static void demux_ogg_check_comments(demuxer_t *d, ogg_stream_t *os, int id, vor
if (os->text && d->sub->id < 0 && demux_ogg_check_lang(val, dvdsub_lang))
{
d->sub->id = index;
- dvdsub_id = index;
+ d->opts->sub_id = index;
mp_msg(MSGT_DEMUX, MSGL_V, "Ogg demuxer: Displaying subtitle stream id %d which matched -slang %s\n", id, val);
}
else
@@ -491,7 +491,7 @@ static int demux_ogg_add_packet(demux_stream_t* ds,ogg_stream_t* os,int id,ogg_p
/// if -forceidx build a table of all syncpoints to make seeking easier
/// otherwise try to get at least the final_granulepos
-void demux_ogg_scan_stream(demuxer_t* demuxer) {
+static void demux_ogg_scan_stream(demuxer_t* demuxer) {
ogg_demuxer_t* ogg_d = demuxer->priv;
stream_t *s = demuxer->stream;
ogg_sync_state* sync = &ogg_d->sync;
@@ -1216,6 +1216,7 @@ static int demux_ogg_fill_buffer(demuxer_t *d, demux_stream_t *dsds) {
/// For avi with Ogg audio stream we have to create an ogg demuxer for this
// stream, then we join the avi and ogg demuxer with a demuxers demuxer
demuxer_t* init_avi_with_ogg(demuxer_t* demuxer) {
+ struct MPOpts *opts = demuxer->opts;
demuxer_t *od;
ogg_demuxer_t *ogg_d;
stream_t* s;
@@ -1277,7 +1278,7 @@ demuxer_t* init_avi_with_ogg(demuxer_t* demuxer) {
// Create the ds_stream and the ogg demuxer
s = new_ds_stream(demuxer->audio);
- od = new_demuxer(s,DEMUXER_TYPE_OGG,0,-2,-2,NULL);
+ od = new_demuxer(opts, s,DEMUXER_TYPE_OGG,0,-2,-2,NULL);
/// Add the header packets in the ogg demuxer audio stream
for (i = 0; i < 3; i++) {
diff --git a/libmpdemux/demux_pva.c b/libmpdemux/demux_pva.c
index 2ff8be63e3..af16f1c3da 100644
--- a/libmpdemux/demux_pva.c
+++ b/libmpdemux/demux_pva.c
@@ -62,7 +62,7 @@ typedef struct {
-int pva_sync(demuxer_t * demuxer)
+static int pva_sync(demuxer_t * demuxer)
{
uint8_t buffer[5]={0,0,0,0,0};
int count;
diff --git a/libmpdemux/demux_rtp.cpp b/libmpdemux/demux_rtp.cpp
index aaa525fc4c..fd6dffa0e3 100644
--- a/libmpdemux/demux_rtp.cpp
+++ b/libmpdemux/demux_rtp.cpp
@@ -8,6 +8,7 @@ extern "C" {
#endif
#include "demux_rtp.h"
#include "stheader.h"
+#include "options.h"
}
#include "demux_rtp_internal.h"
@@ -95,8 +96,8 @@ static char* openURL_sip(SIPClient* client, char const* url) {
int rtspStreamOverTCP = 0;
extern int rtsp_port;
-extern "C" int audio_id, video_id, dvdsub_id;
extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
+ struct MPOpts *opts = demuxer->opts;
Boolean success = False;
do {
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
@@ -256,8 +257,9 @@ extern "C" demuxer_t* demux_open_rtp(demuxer_t* demuxer) {
// code to recognize this:
if (demux_is_multiplexed_rtp_stream(demuxer)) {
stream_t* s = new_ds_stream(demuxer->video);
- demuxer_t* od = demux_open(s, DEMUXER_TYPE_UNKNOWN,
- audio_id, video_id, dvdsub_id, NULL);
+ demuxer_t* od = demux_open(opts, s, DEMUXER_TYPE_UNKNOWN,
+ opts->audio_id, opts->video_id, opts->sub_id,
+ NULL);
demuxer = new_demuxers_demuxer(od, od, od);
}
@@ -637,7 +639,7 @@ demux_packet_t* ReadBufferQueue::getPendingBuffer() {
return dp;
}
-static int demux_rtp_control(struct demuxer_st *demuxer, int cmd, void *arg) {
+static int demux_rtp_control(struct demuxer *demuxer, int cmd, void *arg) {
double endpts = ((RTPState*)demuxer->priv)->mediaSession->playEndTime();
switch(cmd) {
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index 74bbd8e559..6c3792b1d9 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -9,6 +9,7 @@
#include <sys/stat.h>
#include "config.h"
+#include "options.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "m_config.h"
@@ -168,7 +169,7 @@ void free_demuxer_stream(demux_stream_t *ds)
free(ds);
}
-demux_stream_t *new_demuxer_stream(struct demuxer_st *demuxer, int id)
+demux_stream_t *new_demuxer_stream(struct demuxer *demuxer, int id)
{
demux_stream_t *ds = malloc(sizeof(demux_stream_t));
ds->buffer_pos = ds->buffer_size = 0;
@@ -214,8 +215,8 @@ static const demuxer_desc_t *get_demuxer_desc_from_type(int file_format)
}
-demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id,
- int s_id, char *filename)
+demuxer_t *new_demuxer(struct MPOpts *opts, stream_t *stream, int type,
+ int a_id, int v_id, int s_id, char *filename)
{
demuxer_t *d = malloc(sizeof(demuxer_t));
memset(d, 0, sizeof(demuxer_t));
@@ -231,6 +232,7 @@ demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id,
d->video = new_demuxer_stream(d, v_id);
d->sub = new_demuxer_stream(d, s_id);
d->type = type;
+ d->opts = opts;
if (type)
if (!(d->desc = get_demuxer_desc_from_type(type)))
mp_msg(MSGT_DEMUXER, MSGL_ERR,
@@ -243,8 +245,6 @@ demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id,
return d;
}
-extern int dvdsub_id;
-
sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid)
{
if (id > MAX_S_STREAMS - 1 || id < 0) {
@@ -259,12 +259,13 @@ sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid)
sh_sub_t *sh = calloc(1, sizeof(sh_sub_t));
demuxer->s_streams[id] = sh;
sh->sid = sid;
+ sh->opts = demuxer->opts;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sid);
}
return demuxer->s_streams[id];
}
-void free_sh_sub(sh_sub_t *sh)
+static void free_sh_sub(sh_sub_t *sh)
{
mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing sh_sub at %p\n", sh);
free(sh->extradata);
@@ -284,11 +285,11 @@ sh_audio_t *new_sh_audio_aid(demuxer_t *demuxer, int id, int aid)
MAX_A_STREAMS);
return NULL;
}
- if (demuxer->a_streams[id])
+ if (demuxer->a_streams[id]) {
mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_AudioStreamRedefined, id);
- else {
- sh_audio_t *sh = calloc(1, sizeof(sh_audio_t));
+ } else {
mp_msg(MSGT_DEMUXER, MSGL_V, MSGTR_FoundAudioStream, id);
+ sh_audio_t *sh = calloc(1, sizeof(sh_audio_t));
demuxer->a_streams[id] = sh;
sh->aid = aid;
sh->ds = demuxer->audio;
@@ -297,6 +298,7 @@ sh_audio_t *new_sh_audio_aid(demuxer_t *demuxer, int id, int aid)
sh->sample_format = AF_FORMAT_S16_NE;
sh->audio_out_minsize = 8192; /* default size, maybe not enough for Win32/ACM */
sh->pts = MP_NOPTS_VALUE;
+ sh->opts = demuxer->opts;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", aid);
}
return demuxer->a_streams[id];
@@ -324,11 +326,12 @@ sh_video_t *new_sh_video_vid(demuxer_t *demuxer, int id, int vid)
if (demuxer->v_streams[id])
mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_VideoStreamRedefined, id);
else {
- sh_video_t *sh = calloc(1, sizeof(sh_video_t));
mp_msg(MSGT_DEMUXER, MSGL_V, MSGTR_FoundVideoStream, id);
+ sh_video_t *sh = calloc(1, sizeof *sh);
demuxer->v_streams[id] = sh;
sh->vid = vid;
sh->ds = demuxer->video;
+ sh->opts = demuxer->opts;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ID=%d\n", vid);
}
return demuxer->v_streams[id];
@@ -490,6 +493,14 @@ int ds_fill_buffer(demux_stream_t *ds)
if (!ds->first)
ds->last = NULL;
--ds->packs;
+ /* The code below can set ds->eof to 1 when another stream runs
+ * out of buffer space. That makes sense because in that situation
+ * the calling code should not count on being able to demux more
+ * packets from this stream.
+ * If however the situation improves and we're called again
+ * despite the eof flag then it's better to clear it to avoid
+ * weird behavior. */
+ ds->eof = 0;
return 1;
}
if (demux->audio->packs >= MAX_PACKS
@@ -745,9 +756,6 @@ int get_demuxer_type_from_name(char *demuxer_name, int *force)
int extension_parsing = 1; // 0=off 1=mixed (used only for unstable formats)
-int correct_pts = 0;
-int user_correct_pts = -1;
-
/*
NOTE : Several demuxers may be opened at the same time so
demuxers should NEVER rely on an external var to enable them
@@ -761,9 +769,10 @@ int user_correct_pts = -1;
(ex: tv,mf).
*/
-static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
- int force, int audio_id, int video_id,
- int dvdsub_id, char *filename)
+static demuxer_t *demux_open_stream(struct MPOpts *opts, stream_t *stream,
+ int file_format, int force, int audio_id,
+ int video_id, int dvdsub_id,
+ char *filename)
{
demuxer_t *demuxer = NULL;
@@ -776,7 +785,7 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
// If somebody requested a demuxer check it
if (file_format) {
if ((demuxer_desc = get_demuxer_desc_from_type(file_format))) {
- demuxer = new_demuxer(stream, demuxer_desc->type, audio_id,
+ demuxer = new_demuxer(opts, stream, demuxer_desc->type, audio_id,
video_id, dvdsub_id, filename);
if (demuxer_desc->check_file)
fformat = demuxer_desc->check_file(demuxer);
@@ -798,8 +807,9 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
} else {
// Format changed after check, recurse
free_demuxer(demuxer);
- return demux_open_stream(stream, fformat, force, audio_id,
- video_id, dvdsub_id, filename);
+ return demux_open_stream(opts, stream, fformat, force,
+ audio_id, video_id, dvdsub_id,
+ filename);
}
}
// Check failed for forced demuxer, quit
@@ -810,7 +820,7 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
// Test demuxers with safe file checks
for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
if (demuxer_desc->safe_check) {
- demuxer = new_demuxer(stream, demuxer_desc->type, audio_id,
+ demuxer = new_demuxer(opts, stream, demuxer_desc->type, audio_id,
video_id, dvdsub_id, filename);
if ((fformat = demuxer_desc->check_file(demuxer)) != 0) {
if (fformat == demuxer_desc->type) {
@@ -829,7 +839,7 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
return demuxer; // handled in mplayer.c
// Format changed after check, recurse
free_demuxer(demuxer);
- demuxer = demux_open_stream(stream, fformat, force,
+ demuxer = demux_open_stream(opts, stream, fformat, force,
audio_id, video_id,
dvdsub_id, filename);
if (demuxer)
@@ -851,8 +861,9 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
file_format = demuxer_type_by_filename(filename);
if (file_format != DEMUXER_TYPE_UNKNOWN) {
// we like recursion :)
- demuxer = demux_open_stream(stream, file_format, force, audio_id,
- video_id, dvdsub_id, filename);
+ demuxer = demux_open_stream(opts, stream, file_format, force,
+ audio_id, video_id, dvdsub_id,
+ filename);
if (demuxer)
return demuxer; // done!
file_format = DEMUXER_TYPE_UNKNOWN; // continue fuzzy guessing...
@@ -863,7 +874,7 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
// Try detection for all other demuxers
for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
if (!demuxer_desc->safe_check && demuxer_desc->check_file) {
- demuxer = new_demuxer(stream, demuxer_desc->type, audio_id,
+ demuxer = new_demuxer(opts, stream, demuxer_desc->type, audio_id,
video_id, dvdsub_id, filename);
if ((fformat = demuxer_desc->check_file(demuxer)) != 0) {
if (fformat == demuxer_desc->type) {
@@ -882,7 +893,7 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
return demuxer; // handled in mplayer.c
// Format changed after check, recurse
free_demuxer(demuxer);
- demuxer = demux_open_stream(stream, fformat, force,
+ demuxer = demux_open_stream(opts, stream, fformat, force,
audio_id, video_id,
dvdsub_id, filename);
if (demuxer)
@@ -940,8 +951,9 @@ extern int hr_mp3_seek;
extern float stream_cache_min_percent;
extern float stream_cache_seek_min_percent;
-demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
- int video_id, int dvdsub_id, char *filename)
+demuxer_t *demux_open(struct MPOpts *opts, stream_t *vs, int file_format,
+ int audio_id, int video_id, int dvdsub_id,
+ char *filename)
{
stream_t *as = NULL, *ss = NULL;
demuxer_t *vd, *ad = NULL, *sd = NULL;
@@ -999,7 +1011,7 @@ demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
}
}
- vd = demux_open_stream(vs, demuxer_type ? demuxer_type : file_format,
+ vd = demux_open_stream(opts, vs, demuxer_type ? demuxer_type : file_format,
demuxer_force, audio_stream ? -2 : audio_id,
video_id, sub_stream ? -2 : dvdsub_id, filename);
if (!vd) {
@@ -1010,7 +1022,7 @@ demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
return NULL;
}
if (as) {
- ad = demux_open_stream(as,
+ ad = demux_open_stream(opts, as,
audio_demuxer_type ? audio_demuxer_type : afmt,
audio_demuxer_force, audio_id, -2, -2,
audio_stream);
@@ -1023,7 +1035,8 @@ demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
hr_mp3_seek = 1; // Enable high res seeking
}
if (ss) {
- sd = demux_open_stream(ss, sub_demuxer_type ? sub_demuxer_type : sfmt,
+ sd = demux_open_stream(opts, ss,
+ sub_demuxer_type ? sub_demuxer_type : sfmt,
sub_demuxer_force, -2, -2, dvdsub_id,
sub_stream);
if (!sd) {
@@ -1042,10 +1055,11 @@ demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
else
res = vd;
- correct_pts = user_correct_pts;
- if (correct_pts < 0)
- correct_pts = demux_control(res, DEMUXER_CTRL_CORRECT_PTS, NULL)
- == DEMUXER_CTRL_OK;
+ opts->correct_pts = opts->user_correct_pts;
+ if (opts->correct_pts < 0)
+ opts->correct_pts =
+ demux_control(res, DEMUXER_CTRL_CORRECT_PTS,
+ NULL) == DEMUXER_CTRL_OK;
return res;
}
@@ -1078,9 +1092,8 @@ int demux_seek(demuxer_t *demuxer, float rel_seek_secs, float audio_delay,
mp_msg(MSGT_SEEK, MSGL_WARN, MSGTR_CantSeekFile);
return 0;
}
-
- demux_flush(demuxer);
// clear demux buffers:
+ demux_flush(demuxer);
if (sh_audio)
sh_audio->a_buffer_len = 0;
@@ -1139,8 +1152,8 @@ int demux_info_add(demuxer_t *demuxer, const char *opt, const char *param)
}
}
- info = demuxer->info = (char **) realloc(info,
- (2 * (n + 2)) * sizeof(char *));
+ info = demuxer->info =
+ (char **) realloc(info, (2 * (n + 2)) * sizeof(char *));
info[2 * n] = strdup(opt);
info[2 * n + 1] = strdup(param);
memset(&info[2 * (n + 1)], 0, 2 * sizeof(char *));
diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h
index 5e4f0858e8..f7f69a9fb7 100644
--- a/libmpdemux/demuxer.h
+++ b/libmpdemux/demuxer.h
@@ -7,9 +7,8 @@
#include <string.h>
#include "stream/stream.h"
-#ifdef CONFIG_ASS
-#include "libass/ass_types.h"
-#endif
+
+struct MPOpts;
#ifdef HAVE_BUILTIN_EXPECT
#define likely(x) __builtin_expect ((x) != 0, 1)
@@ -20,7 +19,7 @@
#endif
#define MAX_PACKS 4096
-#define MAX_PACK_BYTES 0x2000000
+#define MAX_PACK_BYTES 0x8000000 // 128 MiB
#define DEMUXER_TYPE_UNKNOWN 0
#define DEMUXER_TYPE_MPEG_ES 1
@@ -101,7 +100,7 @@
#define MP_INPUT_BUFFER_PADDING_SIZE 8
// Holds one packet/frame/whatever
-typedef struct demux_packet_st {
+typedef struct demux_packet {
int len;
double pts;
double endpts;
@@ -110,11 +109,11 @@ typedef struct demux_packet_st {
unsigned char* buffer;
int flags; // keyframe, etc
int refcount; //refcounter for the master packet, if 0, buffer can be free()d
- struct demux_packet_st* master; //pointer to the master packet if this one is a cloned one
- struct demux_packet_st* next;
+ struct demux_packet *master; //pointer to the master packet if this one is a cloned one
+ struct demux_packet *next;
} demux_packet_t;
-typedef struct {
+typedef struct demux_stream {
int buffer_pos; // current buffer position
int buffer_size; // current buffer size
unsigned char* buffer; // current buffer, never free() it, always use free_demux_packet(buffer_ref);
@@ -132,7 +131,7 @@ typedef struct {
demux_packet_t *last; // append new packets from input stream to here
demux_packet_t *current;// needed for refcounting of the buffer
int id; // stream ID (for multiple audio/video streams)
- struct demuxer_st *demuxer; // parent demuxer structure (stream handler)
+ struct demuxer *demuxer; // parent demuxer structure (stream handler)
// ---- asf -----
demux_packet_t *asf_packet; // read asf fragments here
int asf_seq;
@@ -142,7 +141,7 @@ typedef struct {
void* sh;
} demux_stream_t;
-typedef struct demuxer_info_st {
+typedef struct demuxer_info {
char *name;
char *author;
char *encoder;
@@ -154,15 +153,12 @@ typedef struct demuxer_info_st {
#define MAX_V_STREAMS 256
#define MAX_S_STREAMS 256
-struct demuxer_st;
-
-extern int correct_pts;
-extern int user_correct_pts;
+struct demuxer;
/**
* Demuxer description structure
*/
-typedef struct demuxers_desc_st {
+typedef struct demuxer_desc {
const char *info; ///< What is it (long name and/or description)
const char *name; ///< Demuxer name, used with -demuxer switch
const char *shortdesc; ///< Description printed at demuxer detection
@@ -173,26 +169,26 @@ typedef struct demuxers_desc_st {
int safe_check; ///< If 1 detection is safe and fast, do it before file extension check
/// Check if can demux the file, return DEMUXER_TYPE_xxx on success
- int (*check_file)(struct demuxer_st *demuxer); ///< Mandatory if safe_check == 1, else optional
+ int (*check_file)(struct demuxer *demuxer); ///< Mandatory if safe_check == 1, else optional
/// Get packets from file, return 0 on eof
- int (*fill_buffer)(struct demuxer_st *demuxer, demux_stream_t *ds); ///< Mandatory
+ int (*fill_buffer)(struct demuxer *demuxer, demux_stream_t *ds); ///< Mandatory
/// Open the demuxer, return demuxer on success, NULL on failure
- struct demuxer_st* (*open)(struct demuxer_st *demuxer); ///< Optional
+ struct demuxer* (*open)(struct demuxer *demuxer); ///< Optional
/// Close the demuxer
- void (*close)(struct demuxer_st *demuxer); ///< Optional
+ void (*close)(struct demuxer *demuxer); ///< Optional
// Seek
- void (*seek)(struct demuxer_st *demuxer, float rel_seek_secs, float audio_delay, int flags); ///< Optional
+ void (*seek)(struct demuxer *demuxer, float rel_seek_secs, float audio_delay, int flags); ///< Optional
// Control
- int (*control)(struct demuxer_st *demuxer, int cmd, void *arg); ///< Optional
+ int (*control)(struct demuxer *demuxer, int cmd, void *arg); ///< Optional
} demuxer_desc_t;
-typedef struct demux_chapter_s
+typedef struct demux_chapter
{
uint64_t start, end;
char* name;
} demux_chapter_t;
-typedef struct demux_attachment_s
+typedef struct demux_attachment
{
char* name;
char* type;
@@ -200,7 +196,7 @@ typedef struct demux_attachment_s
unsigned int data_size;
} demux_attachment_t;
-typedef struct demuxer_st {
+typedef struct demuxer {
const demuxer_desc_t *desc; ///< Demuxer description structure
off_t filepos; // input stream current pos.
off_t movi_start;
@@ -219,9 +215,9 @@ typedef struct demuxer_st {
demux_stream_t *sub; // dvd subtitle buffer/demuxer
// stream headers:
- void* a_streams[MAX_A_STREAMS]; // audio streams (sh_audio_t)
- void* v_streams[MAX_V_STREAMS]; // video sterams (sh_video_t)
- void *s_streams[MAX_S_STREAMS]; // dvd subtitles (flag)
+ struct sh_audio *a_streams[MAX_A_STREAMS];
+ struct sh_video *v_streams[MAX_V_STREAMS];
+ struct sh_sub *s_streams[MAX_S_STREAMS];
demux_chapter_t* chapters;
int num_chapters;
@@ -231,6 +227,7 @@ typedef struct demuxer_st {
void* priv; // fileformat-dependent data
char** info;
+ struct MPOpts *opts;
} demuxer_t;
typedef struct {
@@ -312,8 +309,8 @@ static inline void *realloc_struct(void *ptr, size_t nmemb, size_t size) {
return realloc(ptr, nmemb * size);
}
-demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id);
-demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id,char *filename);
+demux_stream_t* new_demuxer_stream(struct demuxer *demuxer,int id);
+demuxer_t* new_demuxer(struct MPOpts *opts, stream_t *stream,int type,int a_id,int v_id,int s_id,char *filename);
void free_demuxer_stream(demux_stream_t *ds);
void free_demuxer(demuxer_t *demuxer);
@@ -376,7 +373,7 @@ static inline int avi_stream_id(unsigned int id){
return a*10+b;
}
-demuxer_t* demux_open(stream_t *stream,int file_format,int aid,int vid,int sid,char* filename);
+demuxer_t* demux_open(struct MPOpts *opts, stream_t *stream,int file_format,int aid,int vid,int sid,char* filename);
void demux_flush(demuxer_t *demuxer);
int demux_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags);
demuxer_t* new_demuxers_demuxer(demuxer_t* vd, demuxer_t* ad, demuxer_t* sd);
diff --git a/libmpdemux/mp3_hdr.c b/libmpdemux/mp3_hdr.c
index cb59878466..da1826215c 100644
--- a/libmpdemux/mp3_hdr.c
+++ b/libmpdemux/mp3_hdr.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include "config.h"
+#include "mp3_hdr.h"
#include "mp_msg.h"
//----------------------- mp3 audio frame header parser -----------------------
@@ -19,7 +20,7 @@ static long freqs[9] = { 44100, 48000, 32000, // MPEG 1.0
22050, 24000, 16000, // MPEG 2.0
11025, 12000, 8000}; // MPEG 2.5
-int mp_mp3_get_lsf(unsigned char* hbuf){
+static int mp_mp3_get_lsf(unsigned char* hbuf){
unsigned long newhead =
hbuf[0] << 24 |
hbuf[1] << 16 |
diff --git a/libmpdemux/parse_mp4.c b/libmpdemux/parse_mp4.c
index 67ccce5a94..6e4441a17c 100644
--- a/libmpdemux/parse_mp4.c
+++ b/libmpdemux/parse_mp4.c
@@ -36,7 +36,7 @@
#define MP4_DL MSGL_V
#define freereturn(a,b) free(a); return b
-int mp4_read_descr_len(stream_t *s) {
+static int mp4_read_descr_len(stream_t *s) {
uint8_t b;
uint8_t numBytes = 0;
uint32_t length = 0;
diff --git a/libmpdemux/stheader.h b/libmpdemux/stheader.h
index 07ecfaeded..67fa0e1fb4 100644
--- a/libmpdemux/stheader.h
+++ b/libmpdemux/stheader.h
@@ -1,16 +1,17 @@
#ifndef MPLAYER_STHEADER_H
#define MPLAYER_STHEADER_H
-#include "demuxer.h"
#include "aviheader.h"
#include "ms_hdr.h"
+struct MPOpts;
// Stream headers:
-typedef struct {
+typedef struct sh_audio {
+ struct MPOpts *opts;
int aid;
- demux_stream_t *ds;
- struct codecs_st *codec;
+ struct demux_stream *ds;
+ struct codecs *codec;
unsigned int format;
int initialized;
float stream_delay; // number of seconds stream should be delayed (according to dwStart or similar)
@@ -36,8 +37,8 @@ typedef struct {
int a_out_buffer_len;
int a_out_buffer_size;
// void* audio_out; // the audio_out handle, used for this audio stream
- struct af_stream_s *afilter; // the audio filter stream
- struct ad_functions_s* ad_driver;
+ struct af_stream *afilter; // the audio filter stream
+ struct ad_functions *ad_driver;
#ifdef CONFIG_DYNAMIC_PLUGINS
void *dec_handle;
#endif
@@ -54,10 +55,11 @@ typedef struct {
int default_track;
} sh_audio_t;
-typedef struct {
+typedef struct sh_video {
+ struct MPOpts *opts;
int vid;
- demux_stream_t *ds;
- struct codecs_st *codec;
+ struct demux_stream *ds;
+ struct codecs *codec;
unsigned int format;
int initialized;
float timer; // absolute time in video stream, since last start/seek
@@ -81,7 +83,9 @@ typedef struct {
int disp_w,disp_h; // display size (filled by fileformat parser)
// output driver/filters: (set by libmpcodecs core)
unsigned int outfmtidx;
- struct vf_instance_s *vfilter; // the video filter chain, used for this video stream
+ struct vf_instance *vfilter; // the video filter chain, used for this video stream
+ int output_flags; // query_format() results for output filters+vo
+ const struct vd_functions *vd_driver;
int vf_initialized;
#ifdef CONFIG_DYNAMIC_PLUGINS
void *dec_handle;
@@ -94,14 +98,13 @@ typedef struct {
void* context; // codec-specific stuff (usually HANDLE or struct pointer)
} sh_video_t;
-typedef struct {
+typedef struct sh_sub {
+ struct MPOpts *opts;
int sid;
char type; // t = text, v = VobSub, a = SSA/ASS
unsigned char* extradata; // extra header data passed from demuxer
int extradata_len;
-#ifdef CONFIG_ASS
- ass_track_t* ass_track; // for SSA/ASS streams (type == 'a')
-#endif
+ struct ass_track_s *ass_track; // for SSA/ASS streams (type == 'a')
char* lang; // track language
int default_track;
} sh_sub_t;