diff options
49 files changed, 137 insertions, 10972 deletions
diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst index 70f6fd71ec..eeac7fada9 100644 --- a/DOCS/man/en/changes.rst +++ b/DOCS/man/en/changes.rst @@ -104,7 +104,6 @@ Command Line Switches ``-subdelay`` ``--sub-delay`` ``-subpos`` ``--sub-pos`` ``-forcedsubsonly`` ``--sub-forced-only`` - ``-ni`` ``--avi-ni`` ``-benchmark`` ``--untimed`` (no stats) ``-xineramascreen`` ``--screen`` (different values) ``-ss`` ``--start`` diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 8faebfeab8..915602aaca 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -1253,20 +1253,10 @@ depends on the VO backend and how it handles keyboard input. Does not apply to terminal input.) -``--avi-ni`` - (Internal AVI demuxer which is not used by default only) - Force usage of non-interleaved AVI parser (fixes playback of some bad AVI - files). - ``--no-aspect`` Ignore aspect ratio information from video file and assume the video has square pixels. See also ``--aspect``. -``--no-bps`` - (Internal AVI demuxer which is not used by default only) - Do not use average byte/second value for A-V sync. Helps with some AVI - files with broken header. - ``--no-cache`` Turn off input stream caching. See ``--cache``. @@ -185,24 +185,14 @@ SOURCES = talloc.c \ core/timeline/tl_edl.c \ core/timeline/tl_matroska.c \ core/timeline/tl_cue.c \ - demux/asfheader.c \ - demux/aviheader.c \ - demux/aviprint.c \ demux/codec_tags.c \ demux/demux.c \ - demux/demux_asf.c \ - demux/demux_avi.c \ demux/demux_edl.c \ demux/demux_cue.c \ demux/demux_lavf.c \ demux/demux_mf.c \ demux/demux_mkv.c \ - demux/demux_mpg.c \ demux/demux_subreader.c \ - demux/demux_ts.c \ - demux/mp3_hdr.c \ - demux/parse_es.c \ - demux/mpeg_hdr.c \ demux/demux_rawaudio.c \ demux/demux_rawvideo.c \ demux/ebml.c \ diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index b5a4ee1ef8..2495012e47 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -344,7 +344,6 @@ static int control(sh_audio_t *sh, int cmd, void *arg) switch (cmd) { case ADCTRL_RESYNC_STREAM: avcodec_flush_buffers(ctx->avctx); - ds_clear_parser(sh->ds); ctx->previous_data_left = 0; ctx->output_left = 0; return CONTROL_TRUE; @@ -384,10 +383,7 @@ static int decode_new_packet(struct sh_audio *sh) if (!mpkt) { assert(!priv->previous_data_left); start = NULL; - insize = 0; - ds_parse(sh->ds, &start, &insize, pts, 0); - if (insize <= 0) - return -1; // error or EOF + return -1; // error or EOF } else { assert(mpkt->len >= priv->previous_data_left); if (!priv->previous_data_left) { @@ -396,8 +392,7 @@ static int decode_new_packet(struct sh_audio *sh) } insize = priv->previous_data_left; start = mpkt->buffer + mpkt->len - priv->previous_data_left; - int consumed = ds_parse(sh->ds, &start, &insize, pts, 0); - priv->previous_data_left -= consumed; + priv->previous_data_left -= insize; priv->previous_data_left = FFMAX(priv->previous_data_left, 0); } @@ -420,7 +415,7 @@ static int decode_new_packet(struct sh_audio *sh) return -1; } // The "insize >= ret" test is sanity check against decoder overreads - if (!sh->parser && insize >= ret) + if (insize >= ret) priv->previous_data_left = insize - ret; if (!got_frame) return 0; diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index 1314110062..49b7d9a0d8 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -132,20 +132,8 @@ static int init(sh_audio_t *sh, const char *decoder) pts = MP_NOPTS_VALUE; x = 0; } - ds_parse(sh->ds, &start, &x, pts, 0); srate = 48000; //fake value bps = 768000/8; //fake value - if (x && sh->avctx) { // we have parser and large enough buffer - if (sh->avctx->sample_rate < 44100) { - mp_msg(MSGT_DECAUDIO,MSGL_INFO, - "This stream sample_rate[%d Hz] may be broken. " - "Force reset 48000Hz.\n", - sh->avctx->sample_rate); - srate = 48000; //fake value - } else - srate = sh->avctx->sample_rate; - bps = sh->avctx->bit_rate/8; - } sh->ds->buffer_pos -= in_size; int num_channels = 0; @@ -239,14 +227,10 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf, break; x = ds_get_packet_pts(sh->ds, &start, &pts); if (x <= 0) { - x = 0; - ds_parse(sh->ds, &start, &x, MP_NOPTS_VALUE, 0); - if (x == 0) - continue; // END_NOT_FOUND - in_size = x; + continue; // END_NOT_FOUND } else { in_size = x; - consumed = ds_parse(sh->ds, &start, &x, pts, 0); + consumed = x; if (x == 0) { mp_msg(MSGT_DECAUDIO,MSGL_V, "start[%p] in_size[%d] consumed[%d] x[%d].\n", diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index 4f2f462b92..3275bae705 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -21,6 +21,8 @@ #include <unistd.h> #include <assert.h> +#include <libavutil/mem.h> + #include "demux/codec_tags.h" #include "config.h" diff --git a/core/command.c b/core/command.c index 6056596d04..5a68a228bc 100644 --- a/core/command.c +++ b/core/command.c @@ -566,13 +566,13 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg, case M_PROPERTY_SET: angle = demuxer_set_angle(demuxer, *(int *)arg); if (angle >= 0) { - struct sh_video *sh_video = demuxer->video->sh; + struct sh_stream *sh_video = demuxer->video->gsh; if (sh_video) - resync_video_stream(sh_video); + resync_video_stream(sh_video->video); - struct sh_audio *sh_audio = demuxer->audio->sh; + struct sh_stream *sh_audio = demuxer->audio->gsh; if (sh_audio) - resync_audio_stream(sh_audio); + resync_audio_stream(sh_audio->audio); } return M_PROPERTY_OK; case M_PROPERTY_GET_TYPE: { diff --git a/core/mplayer.c b/core/mplayer.c index 79626fdc80..019d37081d 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -375,7 +375,7 @@ static double get_main_demux_pts(struct MPContext *mpctx) if (mpctx->demuxer) { for (int type = 0; type < STREAM_TYPE_COUNT; type++) { struct demux_stream *ds = mpctx->demuxer->ds[type]; - if (ds->sh && main_new_pos == MP_NOPTS_VALUE) { + if (ds->gsh && main_new_pos == MP_NOPTS_VALUE) { demux_fill_buffer(mpctx->demuxer, ds); if (ds->first) main_new_pos = ds->first->pts; @@ -445,11 +445,11 @@ static void preselect_demux_streams(struct MPContext *mpctx) static void uninit_subs(struct demuxer *demuxer) { - for (int i = 0; i < MAX_S_STREAMS; i++) { - struct sh_sub *sh = demuxer->s_streams[i]; - if (sh) { - sub_destroy(sh->dec_sub); - sh->dec_sub = NULL; + for (int i = 0; i < demuxer->num_streams; i++) { + struct sh_stream *sh = demuxer->streams[i]; + if (sh->sub) { + sub_destroy(sh->sub->dec_sub); + sh->sub->dec_sub = NULL; } } } @@ -1938,9 +1938,6 @@ static void reinit_subs(struct MPContext *mpctx) // which makes the demuxer create the sh_stream, and contains the first // subtitle event. - // demux_mpg - maps IDs directly to the logical stream number - track->demuxer->sub->id = track->demuxer_id; - // demux_lavf - IDs are essentially random, have to use MPEG IDs int id = map_id_to_demuxer(track->demuxer, track->type, track->demuxer_id); @@ -2357,25 +2354,20 @@ int reinit_video_chain(struct MPContext *mpctx) goto no_video; } - if (!video_read_properties(mpctx->sh_video)) { - mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Video: Cannot read properties.\n"); - goto err_out; - } else { - mp_tmsg(MSGT_CPLAYER, MSGL_V, "[V] filefmt:%d fourcc:0x%X " - "size:%dx%d fps:%5.3f ftime:=%6.4f\n", - mpctx->master_demuxer->file_format, mpctx->sh_video->format, - mpctx->sh_video->disp_w, mpctx->sh_video->disp_h, - mpctx->sh_video->fps, mpctx->sh_video->frametime); - if (opts->force_fps) { - mpctx->sh_video->fps = opts->force_fps; - mpctx->sh_video->frametime = 1.0f / mpctx->sh_video->fps; - } - update_fps(mpctx); + mp_tmsg(MSGT_CPLAYER, MSGL_V, "[V] filefmt:%d fourcc:0x%X " + "size:%dx%d fps:%5.3f ftime:=%6.4f\n", + mpctx->master_demuxer->file_format, mpctx->sh_video->format, + mpctx->sh_video->disp_w, mpctx->sh_video->disp_h, + mpctx->sh_video->fps, mpctx->sh_video->frametime); + if (opts->force_fps) { + mpctx->sh_video->fps = opts->force_fps; + mpctx->sh_video->frametime = 1.0f / mpctx->sh_video->fps; + } + update_fps(mpctx); - if (!mpctx->sh_video->fps && !opts->force_fps && !opts->correct_pts) { - mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "FPS not specified in the " - "header or invalid, use the -fps option.\n"); - } + if (!mpctx->sh_video->fps && !opts->force_fps && !opts->correct_pts) { + mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "FPS not specified in the " + "header or invalid, use the -fps option.\n"); } double ar = -1.0; @@ -3898,20 +3890,12 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename, stream_enable_cache_percent(&stream, stream_cache, opts->stream_cache_min_percent, opts->stream_cache_seek_min_percent); - // deal with broken demuxers: preselect streams - int vs = -2, as = -2, ss = -2; - switch (filter) { - case STREAM_VIDEO: vs = -1; break; - case STREAM_AUDIO: as = -1; break; - case STREAM_SUB: ss = -1; break; - } - vs = -1; // avi can't go without video struct demuxer_params params = { .ass_library = mpctx->ass_library, // demux_libass requires it }; struct demuxer *demuxer = demux_open_withparams(&mpctx->opts, stream, format, demuxer_name, - as, vs, ss, filename, ¶ms); + filename, ¶ms); if (!demuxer) { free_stream(stream); goto err_out; @@ -4227,7 +4211,6 @@ goto_reopen_demuxer: ; mpctx->audio_delay = opts->audio_delay; mpctx->demuxer = demux_open(opts, mpctx->stream, file_format, - opts->audio_id, opts->video_id, opts->sub_id, mpctx->filename); mpctx->master_demuxer = mpctx->demuxer; diff --git a/core/options.c b/core/options.c index b00f79c003..c0e64b0dcd 100644 --- a/core/options.c +++ b/core/options.c @@ -25,6 +25,7 @@ #include <stddef.h> #include <sys/types.h> +#include <limits.h> #include "core/options.h" #include "config.h" @@ -369,12 +370,9 @@ const m_option_t mp_opts[] = { OPT_FLAG("pause", pause, 0), OPT_FLAG("keep-open", keep_open, 0), - // AVI specific: force non-interleaved mode - {"avi-ni", &force_ni, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - // AVI and Ogg only: (re)build index at startup - {"idx", &index_mode, CONF_TYPE_FLAG, 0, -1, 1, NULL}, - {"forceidx", &index_mode, CONF_TYPE_FLAG, 0, -1, 2, NULL}, + OPT_FLAG_CONSTANTS("idx", index_mode, 0, -1, 1), + OPT_FLAG_STORE("forceidx", index_mode, 0, 2), // select audio/video/subtitle stream OPT_TRACKCHOICE("aid", audio_id), @@ -419,9 +417,6 @@ const m_option_t mp_opts[] = { // ------------------------- a-v sync options -------------------- - // AVI specific: A-V sync mode (bps vs. interleaving) - {"bps", &pts_from_bps, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - // set A-V sync correction speed (0=disables it): OPT_FLOATRANGE("mc", default_max_pts_correction, 0, 0, 100), @@ -804,6 +799,8 @@ const struct MPOpts mp_default_opts = { .hwdec_codecs = "all", + .index_mode = -1, + .ad_lavc_param = { .ac3drc = 1., .downmix = 1, diff --git a/core/options.h b/core/options.h index 1eb111e33e..f7be4adb02 100644 --- a/core/options.h +++ b/core/options.h @@ -160,6 +160,7 @@ typedef struct MPOpts { char *screenshot_template; double force_fps; + int index_mode; // -1=untouched 0=don't use index 1=use (generate) index struct mp_chmap audio_output_channels; int audio_output_format; diff --git a/core/timeline/tl_cue.c b/core/timeline/tl_cue.c index d9160e0b8e..a965cfd877 100644 --- a/core/timeline/tl_cue.c +++ b/core/timeline/tl_cue.c @@ -192,11 +192,7 @@ static bool try_open(struct MPContext *mpctx, char *filename) struct stream *s = open_stream(filename, &mpctx->opts, &format); if (!s) return false; - struct demuxer *d = demux_open(&mpctx->opts, s, format, - mpctx->opts.audio_id, - mpctx->opts.video_id, - mpctx->opts.sub_id, - filename); + struct demuxer *d = demux_open(&mpctx->opts, s, format, filename); // Since .bin files are raw PCM data with no headers, we have to explicitly // open them. Also, try to avoid to open files that are most likely not .bin // files, as that would only play noise. Checking the file extension is @@ -205,11 +201,7 @@ static bool try_open(struct MPContext *mpctx, char *filename) // CD sector size (2352 bytes) if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) { mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: Opening as BIN file!\n"); - d = demux_open(&mpctx->opts, s, DEMUXER_TYPE_RAWAUDIO, - mpctx->opts.audio_id, - mpctx->opts.video_id, - mpctx->opts.sub_id, - filename); + d = demux_open(&mpctx->opts, s, DEMUXER_TYPE_RAWAUDIO, filename); } if (d) { add_source(mpctx, d); diff --git a/core/timeline/tl_edl.c b/core/timeline/tl_edl.c index 5ec04ac716..0303956513 100644 --- a/core/timeline/tl_edl.c +++ b/core/timeline/tl_edl.c @@ -360,9 +360,6 @@ void build_edl_timeline(struct MPContext *mpctx) if (!s) goto openfail; struct demuxer *d = demux_open(&mpctx->opts, s, format, - mpctx->opts.audio_id, - mpctx->opts.video_id, - mpctx->opts.sub_id, edl_ids[i].filename); if (!d) { free_stream(s); diff --git a/core/timeline/tl_matroska.c b/core/timeline/tl_matroska.c index 11fcc67583..6752b5ff4c 100644 --- a/core/timeline/tl_matroska.c +++ b/core/timeline/tl_matroska.c @@ -117,8 +117,7 @@ static struct demuxer *open_demuxer(struct stream *stream, struct MPContext *mpctx, char *filename, struct demuxer_params *params) { return demux_open_withparams(&mpctx->opts, stream, - DEMUXER_TYPE_MATROSKA, NULL, mpctx->opts.audio_id, - mpctx->opts.video_id, mpctx->opts.sub_id, filename, params); + DEMUXER_TYPE_MATROSKA, NULL, filename, params); } static int enable_cache(struct MPContext *mpctx, struct stream **stream, diff --git a/demux/asf.h b/demux/asf.h deleted file mode 100644 index db48f72edb..0000000000 --- a/demux/asf.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_ASF_H -#define MPLAYER_ASF_H - -#include <sys/types.h> -#include <inttypes.h> -#include "libavutil/common.h" -#include "compat/mpbswap.h" - -/////////////////////// -// ASF Object Header -/////////////////////// -typedef struct __attribute__((packed)) { - uint8_t guid[16]; - uint64_t size; -} ASF_obj_header_t; - -//////////////// -// ASF Header -//////////////// -typedef struct __attribute__((packed)) { - ASF_obj_header_t objh; - uint32_t cno; // number of subchunks - uint8_t v1; // unknown (0x01) - uint8_t v2; // unknown (0x02) -} ASF_header_t; - -///////////////////// -// ASF File Header -///////////////////// -typedef struct __attribute__((packed)) { - uint8_t stream_id[16]; // stream GUID - uint64_t file_size; - uint64_t creation_time; //File creation time FILETIME 8 - uint64_t num_packets; //Number of packets UINT64 8 - uint64_t play_duration; //Timestamp of the end position UINT64 8 - uint64_t send_duration; //Duration of the playback UINT64 8 - uint64_t preroll; //Time to bufferize before playing UINT64 8 - uint32_t flags; //Unknown, maybe flags ( usually contains 2 ) UINT32 4 - uint32_t min_packet_size; //Min size of the packet, in bytes UINT32 4 - uint32_t max_packet_size; //Max size of the packet UINT32 4 - uint32_t max_bitrate; //Maximum bitrate of the media (sum of all the stream) -} ASF_file_header_t; - -/////////////////////// -// ASF Stream Header -/////////////////////// -typedef struct __attribute__((packed)) { - uint8_t type[16]; // Stream type (audio/video) GUID 16 - uint8_t concealment[16]; // Audio error concealment type GUID 16 - uint64_t unk1; // Unknown, maybe reserved ( usually contains 0 ) UINT64 8 - uint32_t type_size; //Total size of type-specific data UINT32 4 - uint32_t stream_size; //Size of stream-specific data UINT32 4 - uint16_t stream_no; //Stream number UINT16 2 - uint32_t unk2; //Unknown UINT32 4 -} ASF_stream_header_t; - -/////////////////////////// -// ASF Content Description -/////////////////////////// -typedef struct __attribute__((packed)) { - uint16_t title_size; - uint16_t author_size; - uint16_t copyright_size; - uint16_t comment_size; - uint16_t rating_size; -} ASF_content_description_t; - -//////////////////////// -// ASF Segment Header -//////////////////////// -typedef struct __attribute__((packed)) { - uint8_t streamno; - uint8_t seq; - uint32_t x; - uint8_t flag; -} ASF_segmhdr_t; - -////////////////////// -// ASF Stream Chunck -////////////////////// -typedef struct __attribute__((packed)) { - uint16_t type; - uint16_t size; - uint32_t sequence_number; - uint16_t unknown; - uint16_t size_confirm; -} ASF_stream_chunck_t; - -// Definition of the stream type -#if BYTE_ORDER == BIG_ENDIAN - #define ASF_STREAMING_CLEAR 0x2443 // $C - #define ASF_STREAMING_DATA 0x2444 // $D - #define ASF_STREAMING_END_TRANS 0x2445 // $E - #define ASF_STREAMING_HEADER 0x2448 // $H -#else - #define ASF_STREAMING_CLEAR 0x4324 // $C - #define ASF_STREAMING_DATA 0x4424 // $D - #define ASF_STREAMING_END_TRANS 0x4524 // $E - #define ASF_STREAMING_HEADER 0x4824 // $H -#endif - -// Definition of the differents type of ASF streaming -typedef enum { - ASF_Unknown_e, - ASF_Live_e, - ASF_Prerecorded_e, - ASF_Redirector_e, - ASF_PlainText_e, - ASF_Authenticate_e -} ASF_StreamType_e; - -typedef struct { - ASF_StreamType_e streaming_type; - int request; - int packet_size; - int *audio_streams,n_audio,*video_streams,n_video; - int audio_id, video_id; -} asf_http_streaming_ctrl_t; - - -/* - * Some macros to swap little endian structures read from an ASF file - * into machine endian format - */ -#if BYTE_ORDER == BIG_ENDIAN -#define le2me_ASF_obj_header_t(h) { \ - (h)->size = le2me_64((h)->size); \ -} -#define le2me_ASF_header_t(h) { \ - le2me_ASF_obj_header_t(&(h)->objh); \ - (h)->cno = le2me_32((h)->cno); \ -} -#define le2me_ASF_stream_header_t(h) { \ - (h)->unk1 = le2me_64((h)->unk1); \ - (h)->type_size = le2me_32((h)->type_size); \ - (h)->stream_size = le2me_32((h)->stream_size); \ - (h)->stream_no = le2me_16((h)->stream_no); \ - (h)->unk2 = le2me_32((h)->unk2); \ -} -#define le2me_ASF_fil |