summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--audio/decode/ad_lavc.c18
-rw-r--r--core/av_common.c34
-rw-r--r--core/av_common.h1
-rw-r--r--demux/demux.c14
-rw-r--r--demux/demux_lavf.c90
-rw-r--r--demux/mp_taglists.c158
-rw-r--r--demux/mp_taglists.h28
-rw-r--r--demux/stheader.h5
-rw-r--r--video/decode/vd_lavc.c17
10 files changed, 82 insertions, 284 deletions
diff --git a/Makefile b/Makefile
index 26165505b9..53f97951a1 100644
--- a/Makefile
+++ b/Makefile
@@ -201,7 +201,6 @@ SOURCES = talloc.c \
demux/ebml.c \
demux/extension.c \
demux/mf.c \
- demux/mp_taglists.c \
demux/video.c \
osdep/numcores.c \
osdep/io.c \
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index f6efde4437..1f59280275 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -221,24 +221,23 @@ static int init(sh_audio_t *sh_audio, const char *decoder)
lavc_context = avcodec_alloc_context3(lavc_codec);
ctx->avctx = lavc_context;
ctx->avframe = avcodec_alloc_frame();
+ lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
+ lavc_context->codec_id = lavc_codec->id;
+
+ lavc_context->request_channels = opts->audio_output_channels;
// Always try to set - option only exists for AC3 at the moment
av_opt_set_double(lavc_context, "drc_scale", opts->drc_level,
AV_OPT_SEARCH_CHILDREN);
+
+ lavc_context->codec_tag = sh_audio->format;
lavc_context->sample_rate = sh_audio->samplerate;
lavc_context->bit_rate = sh_audio->i_bps * 8;
- lavc_context->request_channels = opts->audio_output_channels;
- lavc_context->codec_tag = sh_audio->format; //FOURCC
- if (sh_audio->gsh->lavf_codec_tag)
- lavc_context->codec_tag = sh_audio->gsh->lavf_codec_tag;
- lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
- lavc_context->codec_id = lavc_codec->id; // not sure if required, imho not --A'rpi
-
if (sh_audio->wf)
set_from_wf(lavc_context, sh_audio->wf);
- // for QDM2
+ // demux_mkv, demux_mpg
if (sh_audio->codecdata_len && sh_audio->codecdata &&
!lavc_context->extradata) {
lavc_context->extradata = av_malloc(sh_audio->codecdata_len +
@@ -248,6 +247,9 @@ static int init(sh_audio_t *sh_audio, const char *decoder)
lavc_context->extradata_size);
}
+ if (sh_audio->gsh->lav_headers)
+ mp_copy_lav_codec_headers(lavc_context, sh_audio->gsh->lav_headers);
+
/* open it */
if (avcodec_open2(lavc_context, lavc_codec, NULL) < 0) {
mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Could not open codec.\n");
diff --git a/core/av_common.c b/core/av_common.c
index 55fa5e086b..d67852eb86 100644
--- a/core/av_common.c
+++ b/core/av_common.c
@@ -23,6 +23,40 @@
#include "codecs.h"
+// Copy the codec-related fields from st into avctx. This does not set the
+// codec itself, only codec related header data provided by libavformat.
+// The goal is to initialize a new decoder with the header data provided by
+// libavformat, and unlike avcodec_copy_context(), allow the user to create
+// a clean AVCodecContext for a manually selected AVCodec.
+// This is strictly for decoding only.
+void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st)
+{
+ if (st->extradata_size) {
+ av_free(avctx->extradata);
+ avctx->extradata_size = 0;
+ avctx->extradata =
+ av_mallocz(st->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (avctx->extradata) {
+ avctx->extradata_size = st->extradata_size;
+ memcpy(avctx->extradata, st->extradata, st->extradata_size);
+ }
+ }
+ avctx->codec_tag = st->codec_tag;
+ avctx->stream_codec_tag = st->stream_codec_tag;
+ avctx->bit_rate = st->bit_rate;
+ avctx->width = st->width;
+ avctx->height = st->height;
+ avctx->pix_fmt = st->pix_fmt;
+ avctx->sample_aspect_ratio = st->sample_aspect_ratio;
+ avctx->chroma_sample_location = st->chroma_sample_location;
+ avctx->sample_rate = st->sample_rate;
+ avctx->channels = st->channels;
+ avctx->block_align = st->block_align;
+ avctx->channel_layout = st->channel_layout;
+ avctx->audio_service_type = st->audio_service_type;
+ avctx->bits_per_coded_sample = st->bits_per_coded_sample;
+}
+
#if !HAVE_AVCODEC_IS_DECODER_API
static int av_codec_is_decoder(AVCodec *codec)
{
diff --git a/core/av_common.h b/core/av_common.h
index 4fbe592f11..25593ed3d0 100644
--- a/core/av_common.h
+++ b/core/av_common.h
@@ -23,6 +23,7 @@
struct mp_decoder_list;
+void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st);
void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type);
int mp_codec_to_av_codec_id(const char *codec);
const char *mp_codec_from_av_codec_id(int codec_id);
diff --git a/demux/demux.c b/demux/demux.c
index 2ebd79b863..848828acb2 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -339,6 +339,14 @@ static struct sh_stream *new_sh_stream(demuxer_t *demuxer,
return sh;
}
+static void free_sh_stream(struct sh_stream *sh)
+{
+ if (sh->lav_headers) {
+ avcodec_close(sh->lav_headers);
+ av_free(sh->lav_headers);
+ }
+}
+
sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid)
{
if (id > MAX_S_STREAMS - 1 || id < 0) {
@@ -372,7 +380,7 @@ 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);
clear_parser((sh_common_t *)sh);
- talloc_free(sh);
+ free_sh_stream(sh->gsh);
}
sh_audio_t *new_sh_audio_aid(demuxer_t *demuxer, int id, int aid)
@@ -401,7 +409,7 @@ static void free_sh_audio(demuxer_t *demuxer, int id)
free(sh->wf);
free(sh->codecdata);
clear_parser((sh_common_t *)sh);
- talloc_free(sh);
+ free_sh_stream(sh->gsh);
}
sh_video_t *new_sh_video_vid(demuxer_t *demuxer, int id, int vid)
@@ -427,7 +435,7 @@ static void free_sh_video(sh_video_t *sh)
mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing sh_video at %p\n", sh);
free(sh->bih);
clear_parser((sh_common_t *)sh);
- talloc_free(sh);
+ free_sh_stream(sh->gsh);
}
void free_demuxer(demuxer_t *demuxer)
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 7ae063777a..ca81a45f84 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -46,8 +46,6 @@
#include "stheader.h"
#include "core/m_option.h"
-#include "mp_taglists.h"
-
#define INITIAL_PROBE_SIZE STREAM_BUFFER_SIZE
#define PROBE_BUF_SIZE (2 * 1024 * 1024)
@@ -329,100 +327,36 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
AVStream *st = avfc->streams[i];
AVCodecContext *codec = st->codec;
struct sh_stream *sh = NULL;
- // Work around collisions resulting from the hacks changing codec_tag.
- int lavf_codec_tag = codec->codec_tag;
- // Don't use native MPEG codec tag values with our generic tag tables.
- // May contain for example value 3 for MP3, which we'd map to PCM audio.
- if (matches_avinputformat_name(priv, "mpeg") ||
- matches_avinputformat_name(priv, "mpegts"))
- codec->codec_tag = 0;
- int override_tag = mp_taglist_override(codec->codec_id);
- // For some formats (like PCM) always trust CODEC_ID_* more than codec_tag
- if (override_tag)
- codec->codec_tag = override_tag;
-
- const char *mp_codec = mp_codec_from_av_codec_id(codec->codec_id);
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO: {
- WAVEFORMATEX *wf;
- sh_audio_t *sh_audio;
- sh_audio = new_sh_audio_aid(demuxer, i, priv->audio_streams);
+ sh_audio_t *sh_audio = new_sh_audio_aid(demuxer, i, priv->audio_streams);
if (!sh_audio)
break;
sh = sh_audio->gsh;
priv->astreams[priv->audio_streams] = i;
- wf = calloc(sizeof(*wf) + codec->extradata_size, 1);
- // mp4a tag is used for all mp4 files no matter what they actually contain
- if (codec->codec_tag == MKTAG('m', 'p', '4', 'a'))
- codec->codec_tag = 0;
- if (!codec->codec_tag)
- codec->codec_tag = mp_taglist_audio(codec->codec_id);
- if (!codec->codec_tag)
- codec->codec_tag = -1;
- wf->wFormatTag = codec->codec_tag;
- wf->nChannels = codec->channels;
- wf->nSamplesPerSec = codec->sample_rate;
- wf->nAvgBytesPerSec = codec->bit_rate / 8;
- wf->nBlockAlign = codec->block_align;
- wf->wBitsPerSample = codec->bits_per_coded_sample;
- wf->cbSize = codec->extradata_size;
- if (codec->extradata_size)
- memcpy(wf + 1, codec->extradata, codec->extradata_size);
- sh_audio->wf = wf;
sh_audio->ds = demuxer->audio;
sh_audio->format = codec->codec_tag;
+
+ // probably unneeded
sh_audio->channels = codec->channels;
sh_audio->samplerate = codec->sample_rate;
sh_audio->i_bps = codec->bit_rate / 8;
- switch (codec->codec_id) {
- case CODEC_ID_PCM_ALAW:
- sh_audio->format = 0x6;
- break;
- case CODEC_ID_PCM_MULAW:
- sh_audio->format = 0x7;
- break;
- }
+
st->discard = AVDISCARD_ALL;
priv->audio_streams++;
break;
}
case AVMEDIA_TYPE_VIDEO: {
- sh_video_t *sh_video;
- BITMAPINFOHEADER *bih;
- sh_video = new_sh_video_vid(demuxer, i, priv->video_streams);
+ sh_video_t *sh_video = new_sh_video_vid(demuxer, i, priv->video_streams);
if (!sh_video)
break;
sh = sh_video->gsh;
priv->vstreams[priv->video_streams] = i;
if (st->disposition & AV_DISPOSITION_ATTACHED_PIC)
sh_video->gsh->attached_picture = true;
- bih = calloc(sizeof(*bih) + codec->extradata_size, 1);
-
- if (codec->codec_id == CODEC_ID_RAWVIDEO) {
- switch (codec->pix_fmt) {
- case PIX_FMT_RGB24:
- codec->codec_tag = MKTAG(24, 'B', 'G', 'R');
- case PIX_FMT_BGR24:
- codec->codec_tag = MKTAG(24, 'R', 'G', 'B');
- }
- if (!codec->codec_tag)
- codec->codec_tag = avcodec_pix_fmt_to_codec_tag(codec->pix_fmt);
- } else if (!codec->codec_tag) {
- codec->codec_tag = mp_taglist_video(codec->codec_id);
- /* 0 might mean either unset or rawvideo; if codec_id
- * was not RAWVIDEO assume it's unset
- */
- if (!codec->codec_tag)
- codec->codec_tag = -1;
- }
- bih->biSize = sizeof(*bih) + codec->extradata_size;
- bih->biWidth = codec->width;
- bih->biHeight = codec->height;
- bih->biBitCount = codec->bits_per_coded_sample;
- bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount / 8;
- bih->biCompression = codec->codec_tag;
- sh_video->bih = bih;
+
+ sh_video->format = codec->codec_tag;
sh_video->disp_w = codec->width;
sh_video->disp_h = codec->height;
/* Try to make up some frame rate value, even if it's not reliable.
@@ -441,7 +375,6 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
st->codec->ticks_per_frame);
sh_video->fps = fps;
sh_video->frametime = 1 / fps;
- sh_video->format = bih->biCompression;
if (st->sample_aspect_ratio.num)
sh_video->aspect = codec->width * st->sample_aspect_ratio.num
/ (float)(codec->height * st->sample_aspect_ratio.den);
@@ -455,8 +388,6 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
codec->height, codec->sample_aspect_ratio.den);
sh_video->ds = demuxer->video;
- if (codec->extradata_size)
- memcpy(sh_video->bih + 1, codec->extradata, codec->extradata_size);
if (demuxer->video->id != priv->video_streams
&& demuxer->video->id != -1)
st->discard = AVDISCARD_ALL;
@@ -518,8 +449,11 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
st->discard = AVDISCARD_ALL;
}
if (sh) {
- sh->codec = mp_codec;
- sh->lavf_codec_tag = lavf_codec_tag;
+ sh->codec = mp_codec_from_av_codec_id(codec->codec_id);
+ sh->lav_headers = avcodec_alloc_context3(codec->codec);
+ assert(sh->lav_headers);
+ avcodec_copy_context(sh->lav_headers, codec);
+
if (st->disposition & AV_DISPOSITION_DEFAULT)
sh->default_track = 1;
if (matches_avinputformat_name(priv, "mpeg"))
diff --git a/demux/mp_taglists.c b/demux/mp_taglists.c
deleted file mode 100644
index 2b3968dcf9..0000000000
--- a/demux/mp_taglists.c
+++ /dev/null
@@ -1,158 +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.
- */
-
-#include <libavformat/avformat.h>
-
-#include "config.h"
-#include "mp_taglists.h"
-
-struct tag {
- enum CodecID id;
- unsigned int tag;
-};
-
-static const struct tag mp_wav_tags[] = {
- { CODEC_ID_ADPCM_4XM, MKTAG('4', 'X', 'M', 'A')},
- { CODEC_ID_ADPCM_ADX, MKTAG('S', 'a', 'd', 'x')},
- { CODEC_ID_ADPCM_EA, MKTAG('A', 'D', 'E', 'A')},
- { CODEC_ID_ADPCM_EA_MAXIS_XA, MKTAG('A', 'D', 'X', 'A')},
- { CODEC_ID_ADPCM_IMA_WS, MKTAG('A', 'I', 'W', 'S')},
- { CODEC_ID_ADPCM_THP, MKTAG('T', 'H', 'P', 'A')},
- { CODEC_ID_ADPCM_XA, MKTAG('P', 'S', 'X', 'A')},
- { CODEC_ID_AMR_NB, MKTAG('n', 'b', 0, 0)},
- { CODEC_ID_COOK, MKTAG('c', 'o', 'o', 'k')},
- { CODEC_ID_DSICINAUDIO, MKTAG('D', 'C', 'I', 'A')},
- { CODEC_ID_EAC3, MKTAG('E', 'A', 'C', '3')},
- { CODEC_ID_INTERPLAY_DPCM, MKTAG('I', 'N', 'P', 'A')},
- { CODEC_ID_MLP, MKTAG('M', 'L', 'P', ' ')},
- { CODEC_ID_MP1, 0x50},
- { CODEC_ID_MP4ALS, MKTAG('A', 'L', 'S', ' ')},
- { CODEC_ID_MUSEPACK7, MKTAG('M', 'P', 'C', ' ')},
- { CODEC_ID_MUSEPACK8, MKTAG('M', 'P', 'C', '8')},
- { CODEC_ID_NELLYMOSER, MKTAG('N', 'E', 'L', 'L')},
- { CODEC_ID_PCM_LXF, MKTAG('P', 'L', 'X', 'F')},
- { CODEC_ID_QCELP, MKTAG('Q', 'c', 'l', 'p')},
- { CODEC_ID_QDM2, MKTAG('Q', 'D', 'M', '2')},
- { CODEC_ID_RA_144, MKTAG('1', '4', '_', '4')},
- { CODEC_ID_RA_288, MKTAG('2', '8', '_', '8')},
- { CODEC_ID_ROQ_DPCM, MKTAG('R', 'o', 'Q', 'A')},
- { CODEC_ID_SHORTEN, MKTAG('s', 'h', 'r', 'n')},
- { CODEC_ID_SPEEX, MKTAG('s', 'p', 'x', ' ')},
- { CODEC_ID_TTA, MKTAG('T', 'T', 'A', '1')},
- { CODEC_ID_TWINVQ, MKTAG('T', 'W', 'I', '2')},
- { CODEC_ID_WAVPACK, MKTAG('W', 'V', 'P', 'K')},
- { CODEC_ID_WESTWOOD_SND1, MKTAG('S', 'N', 'D', '1')},
- { CODEC_ID_XAN_DPCM, MKTAG('A', 'x', 'a', 'n')},
- { 0, 0 },
-};
-
-static const struct tag mp_codecid_override_tags[] = {
- { CODEC_ID_AAC, MKTAG('M', 'P', '4', 'A')},
- { CODEC_ID_AAC_LATM, MKTAG('M', 'P', '4', 'L')},
- { CODEC_ID_AC3, 0x2000},
- { CODEC_ID_ADPCM_IMA_AMV, MKTAG('A', 'M', 'V', 'A')},
- { CODEC_ID_BINKAUDIO_DCT, MKTAG('B', 'A', 'U', '1')},
- { CODEC_ID_BINKAUDIO_RDFT, MKTAG('B', 'A', 'U', '2')},
- { CODEC_ID_DTS, 0x2001},
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'd')},
- { CODEC_ID_EAC3, MKTAG('E', 'A', 'C', '3')},
- { CODEC_ID_H264, MKTAG('H', '2', '6', '4')},
- { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'V')},
- { CODEC_ID_PCM_S8, -1},
- { CODEC_ID_PCM_U8, -1},
- { CODEC_ID_PCM_S16BE, -1},
- { CODEC_ID_PCM_S16LE, -1},
- { CODEC_ID_PCM_S24BE, -1},
- { CODEC_ID_PCM_S24LE, -1},
- { CODEC_ID_PCM_S32BE, -1},
- { CODEC_ID_PCM_S32LE, -1},
- { CODEC_ID_PCM_BLURAY, MKTAG('B', 'P', 'C', 'M')},
- { CODEC_ID_MP2, 0x50},
- { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'P', 'G', '2')},
- { CODEC_ID_TRUEHD, MKTAG('T', 'R', 'H', 'D')},
- { 0, 0 },
-};
-
-static const struct tag mp_bmp_tags[] = {
- { CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'V')},
- { CODEC_ID_ANM, MKTAG('A', 'N', 'M', ' ')},
- { CODEC_ID_AVS, MKTAG('A', 'V', 'S', ' ')},
- { CODEC_ID_BETHSOFTVID, MKTAG('B', 'E', 'T', 'H')},
- { CODEC_ID_BFI, MKTAG('B', 'F', 'I', 'V')},
- { CODEC_ID_C93, MKTAG('C', '9', '3', 'V')},
- { CODEC_ID_CDGRAPHICS, MKTAG('C', 'D', 'G', 'R')},
- { CODEC_ID_DNXHD, MKTAG('A', 'V', 'd', 'n')},
- { CODEC_ID_DSICINVIDEO, MKTAG('D', 'C', 'I', 'V')},
- { CODEC_ID_DXA, MKTAG('D', 'X', 'A', '1')},
- { CODEC_ID_FLIC, MKTAG('F', 'L', 'I', 'C')},
- { CODEC_ID_IDCIN, MKTAG('I', 'D', 'C', 'I')},
- { CODEC_ID_INTERPLAY_VIDEO, MKTAG('I', 'N', 'P', 'V')},
- { CODEC_ID_JV, MKTAG('F', 'F', 'J', 'V')},
- { CODEC_ID_MDEC, MKTAG('M', 'D', 'E', 'C')},
- { CODEC_ID_MOTIONPIXELS, MKTAG('M', 'V', 'I', '1')},
- { CODEC_ID_NUV, MKTAG('N', 'U', 'V', '1')},
- { CODEC_ID_RL2, MKTAG('R', 'L', '2', 'V')},
- { CODEC_ID_ROQ, MKTAG('R', 'o', 'Q', 'V')},
- { CODEC_ID_RV10, MKTAG('R', 'V', '1', '0')},
- { CODEC_ID_RV20, MKTAG('R', 'V', '2', '0')},
- { CODEC_ID_RV30, MKTAG('R', 'V', '3', '0')},
- { CODEC_ID_RV40, MKTAG('R', 'V', '4', '0')},
- { CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3')},
- { CODEC_ID_TGV, MKTAG('f', 'V', 'G', 'T')},
- { CODEC_ID_THP, MKTAG('T', 'H', 'P', 'V')},
- { CODEC_ID_TIERTEXSEQVIDEO, MKTAG('T', 'S', 'E', 'Q')},
- { CODEC_ID_TXD, MKTAG('T', 'X', 'D', 'V')},
- { CODEC_ID_VP6A, MKTAG('V', 'P', '6', 'A')},
- { CODEC_ID_VMDVIDEO, MKTAG('V', 'M', 'D', 'V')},
- { CODEC_ID_WS_VQA, MKTAG('V', 'Q', 'A', 'V')},
- { CODEC_ID_XAN_WC3, MKTAG('W', 'C', '3', 'V')},
- { 0, 0 },
-};
-
-static unsigned int codec_get_tag(const struct tag *tags, enum CodecID id)
-{
- while (tags->id != CODEC_ID_NONE) {
- if (tags->id == id)
- return tags->tag;
- tags++;
- }
- return 0;
-}
-
-unsigned int mp_taglist_override(enum CodecID id)
-{
- return codec_get_tag(mp_codecid_override_tags, id);
-}
-
-unsigned int mp_taglist_video(enum CodecID id)
-{
- const struct AVCodecTag *tags[] = {avformat_get_riff_video_tags(), NULL };
- unsigned int tag = av_codec_get_tag(tags, id);
- if (tag)
- return tag;
- return codec_get_tag(mp_bmp_tags, id);
-}
-
-unsigned int mp_taglist_audio(enum CodecID id)
-{
- const struct AVCodecTag *tags[] = {avformat_get_riff_audio_tags(), NULL };
- unsigned int tag = av_codec_get_tag(tags, id);
- if (tag)
- return tag;
- return codec_get_tag(mp_wav_tags, id);
-}
diff --git a/demux/mp_taglists.h b/demux/mp_taglists.h
deleted file mode 100644
index d23a982a93..0000000000
--- a/demux/mp_taglists.h
+++ /dev/null
@@ -1,28 +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_MP_TAGLISTS_H
-#define MPLAYER_MP_TAGLISTS_H
-
-#include <libavcodec/avcodec.h>
-
-unsigned int mp_taglist_override(enum CodecID id);
-unsigned int mp_taglist_video(enum CodecID id);
-unsigned int mp_taglist_audio(enum CodecID id);
-
-#endif /* MPLAYER_MP_TAGLISTS_H */
diff --git a/demux/stheader.h b/demux/stheader.h
index bf9077ea0a..8d1822c99f 100644
--- a/demux/stheader.h
+++ b/demux/stheader.h
@@ -59,8 +59,9 @@ struct sh_stream {
// E.g. "h264" (usually corresponds to AVCodecDescriptor.name)
const char *codec;
- // Work around other hacks.
- int lavf_codec_tag;
+ // Codec specific header data (set by demux_lavf.c)
+ // Other demuxers use sh_audio->wf and sh_video->bih instead.
+ struct AVCodecContext *lav_headers;
char *title;
char *lang; // language code
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 9801361cb2..9a8aa41888 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -297,16 +297,10 @@ static int init_avctx(sh_video_t *sh, const char *decoder, struct hwdec *hwdec)
avctx->flags |= lavc_param->bitexact;
- avctx->coded_width = sh->disp_w;
- avctx->coded_height = sh->disp_h;
avctx->workaround_bugs = lavc_param->workaround_bugs;
if (lavc_param->gray)
avctx->flags |= CODEC_FLAG_GRAY;
avctx->flags2 |= lavc_param->fast;
- avctx->codec_tag = sh->format;
- if (sh->gsh->lavf_codec_tag)
- avctx->codec_tag = sh->gsh->lavf_codec_tag;
- avctx->stream_codec_tag = sh->video.fccHandler;
avctx->idct_algo = lavc_param->idct_algo;
avctx->error_concealment = lavc_param->error_concealment;
avctx->debug = lavc_param->debug;
@@ -332,6 +326,14 @@ static int init_avctx(sh_video_t *sh, const char *decoder, struct hwdec *hwdec)
// Do this after the above avopt handling in case it changes values
ctx->skip_frame = avctx->skip_frame;
+ avctx->codec_tag = sh->format;
+ avctx->coded_width = sh->disp_w;
+ avctx->coded_height = sh->disp_h;
+
+ // demux_avi only
+ avctx->stream_codec_tag = sh->video.fccHandler;
+
+ // demux_mkv, demux_avi, demux_asf
if (sh->bih)
set_from_bih(avctx, sh->format, sh->bih);
@@ -340,6 +342,9 @@ static int init_avctx(sh_video_t *sh, const char *decoder, struct hwdec *hwdec)
avctx->codec_tag = 0;
}
+ if (sh->gsh->lav_headers)
+ mp_copy_lav_codec_headers(avctx, sh->gsh->lav_headers);
+
/* open it */
if (avcodec_open2(avctx, lavc_codec, NULL) < 0) {
mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n");