Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2016-06-15 13:32:30 +0300
committerHendrik Leppkes <h.leppkes@gmail.com>2016-06-15 13:32:30 +0300
commit6e91e087debdcbf3e019f065e5e0aeb1af8a14f0 (patch)
tree4182934e05ca5234115545e77860a735d677517f /demuxer
parente90cdeac65b1f9f7f1ceed8da3a20203627ef9fa (diff)
Convert demuxer module to codecpar
Diffstat (limited to 'demuxer')
-rw-r--r--demuxer/Demuxers/BDDemuxer.cpp48
-rw-r--r--demuxer/Demuxers/LAVFAudioHelper.cpp80
-rw-r--r--demuxer/Demuxers/LAVFDemuxer.cpp168
-rw-r--r--demuxer/Demuxers/LAVFStreamInfo.cpp165
-rw-r--r--demuxer/Demuxers/LAVFUtils.cpp76
-rw-r--r--demuxer/Demuxers/LAVFUtils.h18
-rw-r--r--demuxer/Demuxers/LAVFVideoHelper.cpp67
7 files changed, 312 insertions, 310 deletions
diff --git a/demuxer/Demuxers/BDDemuxer.cpp b/demuxer/Demuxers/BDDemuxer.cpp
index edcefa34..ed958776 100644
--- a/demuxer/Demuxers/BDDemuxer.cpp
+++ b/demuxer/Demuxers/BDDemuxer.cpp
@@ -367,8 +367,8 @@ STDMETHODIMP CBDDemuxer::OpenMVCExtensionDemuxer(int playItem)
DbgLog((LOG_TRACE, 10, "-> MVC m2ts has %d streams", m_MVCFormatContext->nb_streams));
for (unsigned i = 0; i < m_MVCFormatContext->nb_streams; i++)
{
- if (m_MVCFormatContext->streams[i]->codec->codec_id == AV_CODEC_ID_H264_MVC
- && m_MVCFormatContext->streams[i]->codec->extradata_size > 0)
+ if (m_MVCFormatContext->streams[i]->codecpar->codec_id == AV_CODEC_ID_H264_MVC
+ && m_MVCFormatContext->streams[i]->codecpar->extradata_size > 0)
{
m_MVCStreamIndex = i;
break;
@@ -556,10 +556,10 @@ void CBDDemuxer::ProcessBluRayMetadata()
m_lavfDemuxer->AddMPEGTSStream(mvcStream->id, 0x20);
AVStream *avstream = m_lavfDemuxer->GetAVStreamByPID(mvcStream->id);
if (avstream) {
- avstream->codec->codec_id = AV_CODEC_ID_H264_MVC;
- avstream->codec->extradata = (BYTE *)av_mallocz(mvcStream->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- avstream->codec->extradata_size = mvcStream->codec->extradata_size;
- memcpy(avstream->codec->extradata, mvcStream->codec->extradata, mvcStream->codec->extradata_size);
+ avstream->codecpar->codec_id = AV_CODEC_ID_H264_MVC;
+ avstream->codecpar->extradata = (BYTE *)av_mallocz(mvcStream->codecpar->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ avstream->codecpar->extradata_size = mvcStream->codecpar->extradata_size;
+ memcpy(avstream->codecpar->extradata, mvcStream->codecpar->extradata, mvcStream->codecpar->extradata_size);
}
}
else {
@@ -700,28 +700,28 @@ void CBDDemuxer::ProcessClipInfo(CLPI_CL *clpi, bool overwrite)
if (avstream) {
if (stream->lang[0] != 0)
av_dict_set(&avstream->metadata, "language", (const char *)stream->lang, overwrite ? 0 : AV_DICT_DONT_OVERWRITE);
- if (avstream->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- if (avstream->codec->width == 0 || avstream->codec->height == 0) {
+ if (avstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (avstream->codecpar->width == 0 || avstream->codecpar->height == 0) {
switch(stream->format) {
case BLURAY_VIDEO_FORMAT_480I:
case BLURAY_VIDEO_FORMAT_480P:
- avstream->codec->width = 720;
- avstream->codec->height = 480;
+ avstream->codecpar->width = 720;
+ avstream->codecpar->height = 480;
break;
case BLURAY_VIDEO_FORMAT_576I:
case BLURAY_VIDEO_FORMAT_576P:
- avstream->codec->width = 720;
- avstream->codec->height = 576;
+ avstream->codecpar->width = 720;
+ avstream->codecpar->height = 576;
break;
case BLURAY_VIDEO_FORMAT_720P:
- avstream->codec->width = 1280;
- avstream->codec->height = 720;
+ avstream->codecpar->width = 1280;
+ avstream->codecpar->height = 720;
break;
case BLURAY_VIDEO_FORMAT_1080I:
case BLURAY_VIDEO_FORMAT_1080P:
default:
- avstream->codec->width = 1920;
- avstream->codec->height = 1080;
+ avstream->codecpar->width = 1920;
+ avstream->codecpar->height = 1080;
break;
}
}
@@ -729,16 +729,16 @@ void CBDDemuxer::ProcessClipInfo(CLPI_CL *clpi, bool overwrite)
if (m_MVCPlayback && stream->coding_type == BLURAY_STREAM_TYPE_VIDEO_H264) {
av_dict_set(&avstream->metadata, "stereo_mode", m_pTitle->mvc_base_view_r_flag ? "mvc_rl" : "mvc_lr", 0);
}
- } else if (avstream->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (avstream->codec->channels == 0) {
- avstream->codec->channels = (stream->format == BLURAY_AUDIO_FORMAT_MONO) ? 1 : (stream->format == BLURAY_AUDIO_FORMAT_STEREO) ? 2 : 6;
- avstream->codec->channel_layout = av_get_default_channel_layout(avstream->codec->channels);
- avstream->codec->sample_rate = (stream->rate == BLURAY_AUDIO_RATE_96||stream->rate == BLURAY_AUDIO_RATE_96_COMBO) ? 96000 : (stream->rate == BLURAY_AUDIO_RATE_192||stream->rate == BLURAY_AUDIO_RATE_192_COMBO) ? 192000 : 48000;
- if (avstream->codec->codec_id == AV_CODEC_ID_DTS) {
+ } else if (avstream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (avstream->codecpar->channels == 0) {
+ avstream->codecpar->channels = (stream->format == BLURAY_AUDIO_FORMAT_MONO) ? 1 : (stream->format == BLURAY_AUDIO_FORMAT_STEREO) ? 2 : 6;
+ avstream->codecpar->channel_layout = av_get_default_channel_layout(avstream->codecpar->channels);
+ avstream->codecpar->sample_rate = (stream->rate == BLURAY_AUDIO_RATE_96||stream->rate == BLURAY_AUDIO_RATE_96_COMBO) ? 96000 : (stream->rate == BLURAY_AUDIO_RATE_192||stream->rate == BLURAY_AUDIO_RATE_192_COMBO) ? 192000 : 48000;
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_DTS) {
if (stream->coding_type == BLURAY_STREAM_TYPE_AUDIO_DTSHD)
- avstream->codec->profile = FF_PROFILE_DTS_HD_HRA;
+ avstream->codecpar->profile = FF_PROFILE_DTS_HD_HRA;
else if (stream->coding_type == BLURAY_STREAM_TYPE_AUDIO_DTSHD_MASTER)
- avstream->codec->profile = FF_PROFILE_DTS_HD_MA;
+ avstream->codecpar->profile = FF_PROFILE_DTS_HD_MA;
}
}
}
diff --git a/demuxer/Demuxers/LAVFAudioHelper.cpp b/demuxer/Demuxers/LAVFAudioHelper.cpp
index fdb503c6..6cc34b7f 100644
--- a/demuxer/Demuxers/LAVFAudioHelper.cpp
+++ b/demuxer/Demuxers/LAVFAudioHelper.cpp
@@ -118,41 +118,41 @@ CMediaType CLAVFAudioHelper::initAudioType(AVCodecID codecId, unsigned int &code
}
WAVEFORMATEX *CLAVFAudioHelper::CreateWVFMTEX(const AVStream *avstream, ULONG *size) {
- WAVEFORMATEX *wvfmt = (WAVEFORMATEX *)CoTaskMemAlloc(sizeof(WAVEFORMATEX) + avstream->codec->extradata_size);
+ WAVEFORMATEX *wvfmt = (WAVEFORMATEX *)CoTaskMemAlloc(sizeof(WAVEFORMATEX) + avstream->codecpar->extradata_size);
if (!wvfmt)
return nullptr;
memset(wvfmt, 0, sizeof(WAVEFORMATEX));
- wvfmt->wFormatTag = avstream->codec->codec_tag;
+ wvfmt->wFormatTag = avstream->codecpar->codec_tag;
- wvfmt->nChannels = avstream->codec->channels ? avstream->codec->channels : 2;
- wvfmt->nSamplesPerSec = avstream->codec->sample_rate ? avstream->codec->sample_rate : 48000;
- wvfmt->nAvgBytesPerSec = (DWORD)(avstream->codec->bit_rate / 8);
+ wvfmt->nChannels = avstream->codecpar->channels ? avstream->codecpar->channels : 2;
+ wvfmt->nSamplesPerSec = avstream->codecpar->sample_rate ? avstream->codecpar->sample_rate : 48000;
+ wvfmt->nAvgBytesPerSec = (DWORD)(avstream->codecpar->bit_rate / 8);
- if(avstream->codec->codec_id == AV_CODEC_ID_AAC || avstream->codec->codec_id == AV_CODEC_ID_AAC_LATM) {
+ if(avstream->codecpar->codec_id == AV_CODEC_ID_AAC || avstream->codecpar->codec_id == AV_CODEC_ID_AAC_LATM) {
wvfmt->wBitsPerSample = 0;
wvfmt->nBlockAlign = 1;
} else {
- wvfmt->wBitsPerSample = get_bits_per_sample(avstream->codec);
+ wvfmt->wBitsPerSample = get_bits_per_sample(avstream->codecpar);
- if ( avstream->codec->block_align > 0 ) {
- wvfmt->nBlockAlign = avstream->codec->block_align;
+ if ( avstream->codecpar->block_align > 0 ) {
+ wvfmt->nBlockAlign = avstream->codecpar->block_align;
} else {
if ( wvfmt->wBitsPerSample == 0 ) {
DbgOutString(L"BitsPerSample is 0, no good!");
}
- wvfmt->nBlockAlign = (WORD)(wvfmt->nChannels * av_get_bytes_per_sample(avstream->codec->sample_fmt));
+ wvfmt->nBlockAlign = (WORD)(wvfmt->nChannels * av_get_bytes_per_sample((AVSampleFormat)avstream->codecpar->format));
}
}
if (!wvfmt->nAvgBytesPerSec)
wvfmt->nAvgBytesPerSec = (wvfmt->nSamplesPerSec * wvfmt->nChannels * wvfmt->wBitsPerSample) >> 3;
- if (avstream->codec->extradata_size > 0) {
- wvfmt->cbSize = avstream->codec->extradata_size;
- memcpy((BYTE *)wvfmt + sizeof(WAVEFORMATEX), avstream->codec->extradata, avstream->codec->extradata_size);
+ if (avstream->codecpar->extradata_size > 0) {
+ wvfmt->cbSize = avstream->codecpar->extradata_size;
+ memcpy((BYTE *)wvfmt + sizeof(WAVEFORMATEX), avstream->codecpar->extradata, avstream->codecpar->extradata_size);
}
- *size = sizeof(WAVEFORMATEX) + avstream->codec->extradata_size;
+ *size = sizeof(WAVEFORMATEX) + avstream->codecpar->extradata_size;
return wvfmt;
}
@@ -168,7 +168,7 @@ WAVEFORMATEXFFMPEG *CLAVFAudioHelper::CreateWVFMTEX_FF(const AVStream *avstream,
memset(wfex_ff, 0, sizeof(WAVEFORMATEXFFMPEG));
memcpy(&wfex_ff->wfex, wvfmt, *size);
- wfex_ff->nCodecId = avstream->codec->codec_id;
+ wfex_ff->nCodecId = avstream->codecpar->codec_id;
CoTaskMemFree(wvfmt);
*size = sizeof(WAVEFORMATEXFFMPEG) + wfex_ff->wfex.cbSize;
@@ -184,7 +184,7 @@ WAVEFORMATEX_HDMV_LPCM *CLAVFAudioHelper::CreateWVFMTEX_LPCM(const AVStream *avs
lpcm->cbSize = sizeof(WAVEFORMATEX_HDMV_LPCM) - sizeof(WAVEFORMATEX);
BYTE channel_conf = 0;
- switch (avstream->codec->channel_layout) {
+ switch (avstream->codecpar->channel_layout) {
case AV_CH_LAYOUT_MONO:
channel_conf = 1;
break;
@@ -235,12 +235,12 @@ WAVEFORMATEXTENSIBLE *CLAVFAudioHelper::CreateWFMTEX_RAW_PCM(const AVStream *avs
WAVEFORMATEX *wfe = &wfex->Format;
wfe->wFormatTag = (WORD)subtype.Data1;
- wfe->nChannels = avstream->codec->channels;
- wfe->nSamplesPerSec = avstream->codec->sample_rate;
- if (avstream->codec->sample_fmt == AV_SAMPLE_FMT_S32 && avstream->codec->bits_per_raw_sample > 0) {
- wfe->wBitsPerSample = avstream->codec->bits_per_raw_sample > 24 ? 32 : (avstream->codec->bits_per_raw_sample > 16 ? 24 : 16);
+ wfe->nChannels = avstream->codecpar->channels;
+ wfe->nSamplesPerSec = avstream->codecpar->sample_rate;
+ if (avstream->codecpar->format == AV_SAMPLE_FMT_S32 && avstream->codecpar->bits_per_raw_sample > 0) {
+ wfe->wBitsPerSample = avstream->codecpar->bits_per_raw_sample > 24 ? 32 : (avstream->codecpar->bits_per_raw_sample > 16 ? 24 : 16);
} else {
- wfe->wBitsPerSample = av_get_bytes_per_sample(avstream->codec->sample_fmt) << 3;
+ wfe->wBitsPerSample = av_get_bytes_per_sample((AVSampleFormat)avstream->codecpar->format) << 3;
}
wfe->nBlockAlign = wfe->nChannels * wfe->wBitsPerSample / 8;
wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign;
@@ -249,7 +249,7 @@ WAVEFORMATEXTENSIBLE *CLAVFAudioHelper::CreateWFMTEX_RAW_PCM(const AVStream *avs
if((wfe->wBitsPerSample > 16 || wfe->nSamplesPerSec > 48000) && wfe->nChannels <= 2) {
dwChannelMask = wfe->nChannels == 2 ? (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT) : SPEAKER_FRONT_CENTER;
} else if (wfe->nChannels > 2) {
- dwChannelMask = (DWORD)avstream->codec->channel_layout;
+ dwChannelMask = (DWORD)avstream->codecpar->channel_layout;
if (!dwChannelMask) {
dwChannelMask = (DWORD)av_get_default_channel_layout(wfe->nChannels);
}
@@ -259,8 +259,8 @@ WAVEFORMATEXTENSIBLE *CLAVFAudioHelper::CreateWFMTEX_RAW_PCM(const AVStream *avs
wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wfex->Format.cbSize = sizeof(*wfex) - sizeof(wfex->Format);
wfex->dwChannelMask = dwChannelMask;
- if (avstream->codec->sample_fmt == AV_SAMPLE_FMT_S32 && avstream->codec->bits_per_raw_sample > 0) {
- wfex->Samples.wValidBitsPerSample = avstream->codec->bits_per_raw_sample;
+ if (avstream->codecpar->format == AV_SAMPLE_FMT_S32 && avstream->codecpar->bits_per_raw_sample > 0) {
+ wfex->Samples.wValidBitsPerSample = avstream->codecpar->bits_per_raw_sample;
} else {
wfex->Samples.wValidBitsPerSample = wfex->Format.wBitsPerSample;
}
@@ -286,17 +286,17 @@ MPEG1WAVEFORMAT *CLAVFAudioHelper::CreateMP1WVFMT(const AVStream *avstream, ULON
memset(mpwvfmt, 0, sizeof(MPEG1WAVEFORMAT));
memcpy(&mpwvfmt->wfx, wvfmt, sizeof(WAVEFORMATEX));
- mpwvfmt->dwHeadBitrate = (DWORD)avstream->codec->bit_rate;
- mpwvfmt->fwHeadMode = avstream->codec->channels == 1 ? ACM_MPEG_SINGLECHANNEL : ACM_MPEG_DUALCHANNEL;
- mpwvfmt->fwHeadLayer = (avstream->codec->codec_id == AV_CODEC_ID_MP1) ? ACM_MPEG_LAYER1 : ACM_MPEG_LAYER2;
+ mpwvfmt->dwHeadBitrate = (DWORD)avstream->codecpar->bit_rate;
+ mpwvfmt->fwHeadMode = avstream->codecpar->channels == 1 ? ACM_MPEG_SINGLECHANNEL : ACM_MPEG_DUALCHANNEL;
+ mpwvfmt->fwHeadLayer = (avstream->codecpar->codec_id == AV_CODEC_ID_MP1) ? ACM_MPEG_LAYER1 : ACM_MPEG_LAYER2;
- if (avstream->codec->sample_rate == 0) {
- avstream->codec->sample_rate = 48000;
+ if (avstream->codecpar->sample_rate == 0) {
+ avstream->codecpar->sample_rate = 48000;
}
mpwvfmt->wfx.wFormatTag = WAVE_FORMAT_MPEG;
- mpwvfmt->wfx.nBlockAlign = WORD((avstream->codec->codec_id == AV_CODEC_ID_MP1)
- ? (12 * avstream->codec->bit_rate / avstream->codec->sample_rate) * 4
- : 144 * avstream->codec->bit_rate / avstream->codec->sample_rate);
+ mpwvfmt->wfx.nBlockAlign = WORD((avstream->codecpar->codec_id == AV_CODEC_ID_MP1)
+ ? (12 * avstream->codecpar->bit_rate / avstream->codecpar->sample_rate) * 4
+ : 144 * avstream->codecpar->bit_rate / avstream->codecpar->sample_rate);
mpwvfmt->wfx.cbSize = sizeof(MPEG1WAVEFORMAT) - sizeof(WAVEFORMATEX);
@@ -312,9 +312,9 @@ VORBISFORMAT *CLAVFAudioHelper::CreateVorbis(const AVStream *avstream, ULONG *si
return nullptr;
memset(vfmt, 0, sizeof(VORBISFORMAT));
- vfmt->nChannels = avstream->codec->channels;
- vfmt->nSamplesPerSec = avstream->codec->sample_rate;
- vfmt->nAvgBitsPerSec = (DWORD)avstream->codec->bit_rate;
+ vfmt->nChannels = avstream->codecpar->channels;
+ vfmt->nSamplesPerSec = avstream->codecpar->sample_rate;
+ vfmt->nAvgBitsPerSec = (DWORD)avstream->codecpar->bit_rate;
vfmt->nMinBitsPerSec = vfmt->nMaxBitsPerSec = (DWORD)-1;
*size = sizeof(VORBISFORMAT);
@@ -322,7 +322,7 @@ VORBISFORMAT *CLAVFAudioHelper::CreateVorbis(const AVStream *avstream, ULONG *si
}
VORBISFORMAT2 *CLAVFAudioHelper::CreateVorbis2(const AVStream *avstream, ULONG *size) {
- BYTE *p = avstream->codec->extradata;
+ BYTE *p = avstream->codecpar->extradata;
std::vector<int> sizes;
// read the number of blocks, and then the sizes of the individual blocks
for(BYTE n = *p++; n > 0; n--) {
@@ -337,7 +337,7 @@ VORBISFORMAT2 *CLAVFAudioHelper::CreateVorbis2(const AVStream *avstream, ULONG *
totalsize += sizes[i];
// Get the size of the last block
- sizes.push_back(avstream->codec->extradata_size - (int)(p - avstream->codec->extradata) - totalsize);
+ sizes.push_back(avstream->codecpar->extradata_size - (int)(p - avstream->codecpar->extradata) - totalsize);
totalsize += sizes[sizes.size()-1];
// 3 blocks is the currently valid Vorbis format
@@ -347,9 +347,9 @@ VORBISFORMAT2 *CLAVFAudioHelper::CreateVorbis2(const AVStream *avstream, ULONG *
return nullptr;
memset(pvf2, 0, sizeof(VORBISFORMAT2));
- pvf2->Channels = avstream->codec->channels;
- pvf2->SamplesPerSec = avstream->codec->sample_rate;
- pvf2->BitsPerSample = get_bits_per_sample(avstream->codec);
+ pvf2->Channels = avstream->codecpar->channels;
+ pvf2->SamplesPerSec = avstream->codecpar->sample_rate;
+ pvf2->BitsPerSample = get_bits_per_sample(avstream->codecpar);
BYTE *p2 = (BYTE *)pvf2 + sizeof(VORBISFORMAT2);
for(unsigned int i = 0; i < sizes.size(); p += sizes[i], p2 += sizes[i], i++) {
diff --git a/demuxer/Demuxers/LAVFDemuxer.cpp b/demuxer/Demuxers/LAVFDemuxer.cpp
index 794a87eb..deb032cf 100644
--- a/demuxer/Demuxers/LAVFDemuxer.cpp
+++ b/demuxer/Demuxers/LAVFDemuxer.cpp
@@ -499,7 +499,7 @@ HRESULT CLAVFDemuxer::CheckBDM2TSCPLI(LPCOLESTR pszFileName)
inline static int init_parser(AVFormatContext *s, AVStream *st) {
if (!st->parser && st->need_parsing && !(s->flags & AVFMT_FLAG_NOPARSE)) {
- st->parser = av_parser_init(st->codec->codec_id);
+ st->parser = av_parser_init(st->codecpar->codec_id);
if (st->parser) {
if(st->need_parsing == AVSTREAM_PARSE_HEADERS){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
@@ -515,11 +515,11 @@ inline static int init_parser(AVFormatContext *s, AVStream *st) {
void CLAVFDemuxer::UpdateParserFlags(AVStream *st) {
if (st->parser) {
- if ((st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO || st->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO) && _stricmp(m_pszInputFormat, "mpegvideo") != 0) {
+ if ((st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO || st->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO) && _stricmp(m_pszInputFormat, "mpegvideo") != 0) {
st->parser->flags |= PARSER_FLAG_NO_TIMESTAMP_MANGLING;
- } else if (st->codec->codec_id == AV_CODEC_ID_H264) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
st->parser->flags |= PARSER_FLAG_NO_TIMESTAMP_MANGLING;
- } else if (st->codec->codec_id == AV_CODEC_ID_VC1) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_VC1) {
if (m_bVC1Correction) {
st->parser->flags &= ~PARSER_FLAG_NO_TIMESTAMP_MANGLING;
} else {
@@ -652,12 +652,12 @@ STDMETHODIMP CLAVFDemuxer::InitAVFormat(LPCOLESTR pszFileName, BOOL bForce)
// Disable full stream parsing for these formats
if (st->need_parsing == AVSTREAM_PARSE_FULL) {
- if (st->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
st->need_parsing = AVSTREAM_PARSE_NONE;
}
}
- if (m_bOgg && st->codec->codec_id == AV_CODEC_ID_H264) {
+ if (m_bOgg && st->codecpar->codec_id == AV_CODEC_ID_H264) {
st->need_parsing = AVSTREAM_PARSE_FULL;
}
@@ -667,22 +667,22 @@ STDMETHODIMP CLAVFDemuxer::InitAVFormat(LPCOLESTR pszFileName, BOOL bForce)
#ifdef DEBUG
AVProgram *streamProg = av_find_program_from_stream(m_avFormat, nullptr, idx);
- DbgLog((LOG_TRACE, 30, L"Stream %d (pid %d) - program: %d, codec: %S; parsing: %S;", idx, st->id, streamProg ? streamProg->pmt_pid : -1, avcodec_get_name(st->codec->codec_id), lavf_get_parsing_string(st->need_parsing)));
+ DbgLog((LOG_TRACE, 30, L"Stream %d (pid %d) - program: %d, codec: %S; parsing: %S;", idx, st->id, streamProg ? streamProg->pmt_pid : -1, avcodec_get_name(st->codecpar->codec_id), lavf_get_parsing_string(st->need_parsing)));
#endif
m_stOrigParser[idx] = st->need_parsing;
- if ((st->codec->codec_id == AV_CODEC_ID_DTS && st->codec->codec_tag == 0xA2)
- || (st->codec->codec_id == AV_CODEC_ID_EAC3 && st->codec->codec_tag == 0xA1))
+ if ((st->codecpar->codec_id == AV_CODEC_ID_DTS && st->codecpar->codec_tag == 0xA2)
+ || (st->codecpar->codec_id == AV_CODEC_ID_EAC3 && st->codecpar->codec_tag == 0xA1))
st->disposition |= LAVF_DISPOSITION_SECONDARY_AUDIO;
UpdateSubStreams();
- if (st->codec->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
- if (st->codec->codec_id == AV_CODEC_ID_TTF || st->codec->codec_id == AV_CODEC_ID_OTF) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_TTF || st->codecpar->codec_id == AV_CODEC_ID_OTF) {
if (!m_pFontInstaller) {
m_pFontInstaller = new CFontInstaller();
}
- m_pFontInstaller->InstallFont(st->codec->extradata, st->codec->extradata_size);
+ m_pFontInstaller->InstallFont(st->codecpar->extradata, st->codecpar->extradata_size);
}
const AVDictionaryEntry* attachFilename = av_dict_get(st->metadata, "filename", nullptr, 0);
@@ -693,7 +693,7 @@ STDMETHODIMP CLAVFDemuxer::InitAVFormat(LPCOLESTR pszFileName, BOOL bForce)
LPWSTR chMimetype = CoTaskGetWideCharFromMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, attachMimeType->value, -1);
if (chFilename && chMimetype)
- ResAppend(chFilename, nullptr, chMimetype, st->codec->extradata, (DWORD)st->codec->extradata_size);
+ ResAppend(chFilename, nullptr, chMimetype, st->codecpar->extradata, (DWORD)st->codecpar->extradata_size);
SAFE_CO_FREE(chFilename);
SAFE_CO_FREE(chMimetype);
@@ -716,7 +716,7 @@ STDMETHODIMP CLAVFDemuxer::InitAVFormat(LPCOLESTR pszFileName, BOOL bForce)
for (int c = 0; c < countof(CoverMimeTypes); c++)
{
- if (CoverMimeTypes[c].codec == st->codec->codec_id) {
+ if (CoverMimeTypes[c].codec == st->codecpar->codec_id) {
if (chFilename == nullptr) {
size_t size = wcslen(CoverMimeTypes[c].ext) + 15;
chFilename = (LPWSTR)CoTaskMemAlloc(size * sizeof(wchar_t));
@@ -817,13 +817,13 @@ HRESULT CLAVFDemuxer::SetActiveStream(StreamType type, int pid)
for(unsigned int idx = 0; idx < m_avFormat->nb_streams; ++idx) {
AVStream *st = m_avFormat->streams[idx];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
st->discard = (m_dActiveStreams[video] == idx) ? AVDISCARD_DEFAULT : AVDISCARD_ALL;
// don't discard h264 mvc streams
- if (m_bH264MVCCombine && st->codec->codec_id == AV_CODEC_ID_H264_MVC)
+ if (m_bH264MVCCombine && st->codecpar->codec_id == AV_CODEC_ID_H264_MVC)
st->discard = AVDISCARD_DEFAULT;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
st->discard = (m_dActiveStreams[audio] == idx) ? AVDISCARD_DEFAULT : AVDISCARD_ALL;
// If the stream is a sub stream, make sure to activate the main stream as well
if (m_bMPEGTS && (st->disposition & LAVF_DISPOSITION_SUB_STREAM) && st->discard == AVDISCARD_DEFAULT) {
@@ -835,7 +835,7 @@ HRESULT CLAVFDemuxer::SetActiveStream(StreamType type, int pid)
}
}
}
- } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
st->discard = (m_dActiveStreams[subpic] == idx || (m_dActiveStreams[subpic] == FORCED_SUBTITLE_PID && m_ForcedSubStream == idx)) ? AVDISCARD_DEFAULT : AVDISCARD_ALL;
} else {
st->discard = AVDISCARD_ALL;
@@ -850,7 +850,7 @@ void CLAVFDemuxer::UpdateSubStreams()
for(unsigned int idx = 0; idx < m_avFormat->nb_streams; ++idx) {
AVStream *st = m_avFormat->streams[idx];
// Find and flag the AC-3 substream
- if (m_bMPEGTS && st->codec->codec_id == AV_CODEC_ID_TRUEHD) {
+ if (m_bMPEGTS && st->codecpar->codec_id == AV_CODEC_ID_TRUEHD) {
int id = st->id;
AVStream *sub_st = nullptr;
@@ -940,9 +940,9 @@ void CLAVFDemuxer::SettingsChanged(ILAVFSettingsInternal *pSettings)
for(unsigned int idx = 0; idx < m_avFormat->nb_streams; ++idx) {
AVStream *st = m_avFormat->streams[idx];
- if (st->codec->codec_id == AV_CODEC_ID_VC1) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_VC1) {
UpdateParserFlags(st);
- } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
st->need_parsing = m_stOrigParser[idx];
}
}
@@ -1209,7 +1209,7 @@ STDMETHODIMP CLAVFDemuxer::GetNextPacket(Packet **ppPacket)
}
// Accept H264 MVC streams, as they get combined with the base stream later
- if (m_bH264MVCCombine && stream->codec->codec_id == AV_CODEC_ID_H264_MVC)
+ if (m_bH264MVCCombine && stream->codecpar->codec_id == AV_CODEC_ID_H264_MVC)
streamActive = TRUE;
if(!streamActive) {
@@ -1231,9 +1231,9 @@ STDMETHODIMP CLAVFDemuxer::GetNextPacket(Packet **ppPacket)
pPacket->StreamId = (DWORD)pkt.stream_index;
pPacket->bPosition = pkt.pos;
- if (stream->codec->codec_id == AV_CODEC_ID_H264) {
+ if (stream->codecpar->codec_id == AV_CODEC_ID_H264) {
if (m_bMatroska || m_bOgg) {
- if (!stream->codec->extradata_size || stream->codec->extradata[0] != 1 || AV_RB32(pkt.data) == 0x00000001) {
+ if (!stream->codecpar->extradata_size || stream->codecpar->extradata[0] != 1 || AV_RB32(pkt.data) == 0x00000001) {
pPacket->dwFlags |= LAV_PACKET_H264_ANNEXB;
} else { // No DTS for H264 in native format
dts = Packet::INVALID_TIME;
@@ -1243,19 +1243,19 @@ STDMETHODIMP CLAVFDemuxer::GetNextPacket(Packet **ppPacket)
}
}
- if(m_bAVI && stream->codec && stream->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if(m_bAVI && stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
{
// AVI's always have borked pts, specially if m_pFormatContext->flags includes
// AVFMT_FLAG_GENPTS so always use dts
pts = Packet::INVALID_TIME;
}
- if (stream->codec->codec_id == AV_CODEC_ID_RV10 || stream->codec->codec_id == AV_CODEC_ID_RV20 || stream->codec->codec_id == AV_CODEC_ID_RV30 || stream->codec->codec_id == AV_CODEC_ID_RV40) {
+ if (stream->codecpar->codec_id == AV_CODEC_ID_RV10 || stream->codecpar->codec_id == AV_CODEC_ID_RV20 || stream->codecpar->codec_id == AV_CODEC_ID_RV30 || stream->codecpar->codec_id == AV_CODEC_ID_RV40) {
pts = Packet::INVALID_TIME;
}
// Never use DTS for these formats
- if (!m_bAVI && (stream->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO || stream->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO))
+ if (!m_bAVI && (stream->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO || stream->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO))
dts = Packet::INVALID_TIME;
if(pkt.data) {
@@ -1275,7 +1275,7 @@ STDMETHODIMP CLAVFDemuxer::GetNextPacket(Packet **ppPacket)
rt = dts;
}
- if (stream->codec->codec_id == AV_CODEC_ID_VC1) {
+ if (stream->codecpar->codec_id == AV_CODEC_ID_VC1) {
if (m_bMatroska && m_bVC1Correction) {
rt = pts;
if (!m_bVC1SeenTimestamp) {
@@ -1287,21 +1287,21 @@ STDMETHODIMP CLAVFDemuxer::GetNextPacket(Packet **ppPacket)
rt = dts;
pPacket->dwFlags |= LAV_PACKET_PARSED;
}
- } else if (stream->codec->codec_id == AV_CODEC_ID_MOV_TEXT) {
+ } else if (stream->codecpar->codec_id == AV_CODEC_ID_MOV_TEXT) {
pPacket->dwFlags |= LAV_PACKET_MOV_TEXT;
}
// Mark the packet as parsed, so the forced subtitle parser doesn't hit it
- if (stream->codec->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE && m_bPGSNoParsing) {
+ if (stream->codecpar->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE && m_bPGSNoParsing) {
pPacket->dwFlags |= LAV_PACKET_PARSED;
}
pPacket->rtStart = pPacket->rtStop = rt;
if (rt != Packet::INVALID_TIME) {
- pPacket->rtStop += (duration > 0 || stream->codec->codec_id == AV_CODEC_ID_TRUEHD) ? duration : 1;
+ pPacket->rtStop += (duration > 0 || stream->codecpar->codec_id == AV_CODEC_ID_TRUEHD) ? duration : 1;
}
- if (stream->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ if (stream->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
pPacket->bDiscontinuity = TRUE;
if (forcedSubStream) {
@@ -1309,7 +1309,7 @@ STDMETHODIMP CLAVFDemuxer::GetNextPacket(Packet **ppPacket)
pPacket->dwFlags &= ~LAV_PACKET_PARSED;
}
- if (stream->codec->codec_id == AV_CODEC_ID_SRT) {
+ if (stream->codecpar->codec_id == AV_CODEC_ID_SRT) {
pPacket->dwFlags |= LAV_PACKET_SRT;
}
}
@@ -1320,7 +1320,7 @@ STDMETHODIMP CLAVFDemuxer::GetNextPacket(Packet **ppPacket)
int paramchange_size = 0;
uint8_t *paramchange = av_packet_get_side_data(&pkt, AV_PKT_DATA_PARAM_CHANGE, &paramchange_size);
if ((sidedata && sidedata_size) || (paramchange && paramchange_size)) {
- CreatePacketMediaType(pPacket, stream->codec->codec_id, sidedata, sidedata_size, paramchange, paramchange_size);
+ CreatePacketMediaType(pPacket, stream->codecpar->codec_id, sidedata, sidedata_size, paramchange, paramchange_size);
}
pPacket->bSyncPoint = pkt.flags & AV_PKT_FLAG_KEY;
@@ -1729,9 +1729,9 @@ STDMETHODIMP_(BOOL) CLAVFDemuxer::GetTrackInfo(UINT aTrackIdx, struct TrackEleme
strncpy_s(pStructureToFill->Language, st->language.c_str(), _TRUNCATE);
pStructureToFill->Language[3] = '\0';
- pStructureToFill->Type = (avst->codec->codec_type == AVMEDIA_TYPE_VIDEO) ? TypeVideo :
- (avst->codec->codec_type == AVMEDIA_TYPE_AUDIO) ? TypeAudio :
- (avst->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) ? TypeSubtitle : 0;
+ pStructureToFill->Type = (avst->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ? TypeVideo :
+ (avst->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) ? TypeAudio :
+ (avst->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) ? TypeSubtitle : 0;
}
// The following flags are not exported via avformat
@@ -1754,31 +1754,31 @@ STDMETHODIMP_(BOOL) CLAVFDemuxer::GetTrackExtendedInfo(UINT aTrackIdx, void* pSt
const AVStream *st = m_avFormat->streams[id];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
TrackExtendedInfoVideo* pTEIV = (TrackExtendedInfoVideo*)pStructureToFill;
ZeroMemory(pTEIV, sizeof(*pTEIV));
pTEIV->Size = sizeof(*pTEIV);
pTEIV->DisplayUnit = 0; // always pixels
- pTEIV->DisplayWidth = st->codec->width;
- pTEIV->DisplayHeight = st->codec->height;
+ pTEIV->DisplayWidth = st->codecpar->width;
+ pTEIV->DisplayHeight = st->codecpar->height;
- pTEIV->PixelWidth = st->codec->coded_width ? st->codec->coded_width : st->codec->width;
- pTEIV->PixelHeight = st->codec->coded_height ? st->codec->coded_height : st->codec->height;
+ pTEIV->PixelWidth = st->codecpar->width;
+ pTEIV->PixelHeight = st->codecpar->height;
pTEIV->AspectRatioType = 0;
pTEIV->Interlaced = 0;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
TrackExtendedInfoAudio* pTEIA = (TrackExtendedInfoAudio*)pStructureToFill;
ZeroMemory(pTEIA, sizeof(*pTEIA));
pTEIA->Size = sizeof(*pTEIA);
- pTEIA->BitDepth = st->codec->bits_per_coded_sample;
- pTEIA->Channels = st->codec->channels;
- pTEIA->OutputSamplingFrequency = (FLOAT)st->codec->sample_rate;
- pTEIA->SamplingFreq = (FLOAT)st->codec->sample_rate;
+ pTEIA->BitDepth = st->codecpar->bits_per_coded_sample;
+ pTEIA->Channels = st->codecpar->channels;
+ pTEIA->OutputSamplingFrequency = (FLOAT)st->codecpar->sample_rate;
+ pTEIA->SamplingFreq = (FLOAT)st->codecpar->sample_rate;
}
return TRUE;
@@ -1813,7 +1813,7 @@ STDMETHODIMP_(BSTR) CLAVFDemuxer::GetTrackCodecName(UINT aTrackIdx)
BSTR codecName = nullptr;
- std::string codec = get_codec_name(st->codec);
+ std::string codec = get_codec_name(st->codecpar);
if (!codec.empty()) {
codecName = ConvertCharToBSTR(codec.c_str());
}
@@ -1888,9 +1888,9 @@ STDMETHODIMP CLAVFDemuxer::AddStream(int streamId)
HRESULT hr = S_OK;
AVStream *pStream = m_avFormat->streams[streamId];
- if ( pStream->codec->codec_type == AVMEDIA_TYPE_UNKNOWN
+ if ( pStream->codecpar->codec_type == AVMEDIA_TYPE_UNKNOWN
|| pStream->discard == AVDISCARD_ALL
- || (pStream->codec->codec_id == AV_CODEC_ID_NONE && pStream->codec->codec_tag == 0)
+ || (pStream->codecpar->codec_id == AV_CODEC_ID_NONE && pStream->codecpar->codec_tag == 0)
|| (!m_bSubStreams && (pStream->disposition & LAVF_DISPOSITION_SUB_STREAM))
|| (pStream->disposition & AV_DISPOSITION_ATTACHED_PIC)) {
pStream->discard = AVDISCARD_ALL;
@@ -1923,7 +1923,7 @@ STDMETHODIMP CLAVFDemuxer::AddStream(int streamId)
return hr;
}
- switch(pStream->codec->codec_type)
+ switch(pStream->codecpar->codec_type)
{
case AVMEDIA_TYPE_VIDEO:
m_streams[video].push_back(s);
@@ -1974,17 +1974,17 @@ STDMETHODIMP CLAVFDemuxer::CreateStreams()
for(unsigned k = 0; k < m_avFormat->programs[i]->nb_stream_indexes; ++k) {
unsigned streamIdx = m_avFormat->programs[i]->stream_index[k];
AVStream *st = m_avFormat->streams[streamIdx];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- if (st->codec->width != 0 && st->codec->height != 0) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->width != 0 && st->codecpar->height != 0) {
dwVideoScore = 4;
- DWORD dwResolutionScore = st->codec->width * st->codec->height;
+ DWORD dwResolutionScore = st->codecpar->width * st->codecpar->height;
if (dwResolutionScore > dwVideoResolutionScore)
dwVideoResolutionScore = dwResolutionScore;
}
else if (dwVideoScore == 0)
dwVideoScore = 1;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && dwAudioScore < 4) {
- if (st->codec->channels != 0)
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && dwAudioScore < 4) {
+ if (st->codecpar->channels != 0)
dwAudioScore = 4;
else
dwAudioScore = 1;
@@ -2035,7 +2035,7 @@ STDMETHODIMP CLAVFDemuxer::CreateStreams()
continue;
AVStream *st = m_avFormat->streams[streamIdx];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->duration != AV_NOPTS_VALUE) {
st_duration = av_rescale_q(st->duration, st->time_base, AV_RATIONAL_TIMEBASE);
if (st_duration > duration)
@@ -2048,7 +2048,7 @@ STDMETHODIMP CLAVFDemuxer::CreateStreams()
start_time = st_start_time;
}
}
- if (st->codec->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE)
+ if (st->codecpar->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE)
bHasPGS = true;
}
@@ -2077,7 +2077,7 @@ STDMETHODIMP CLAVFDemuxer::CreateStreams()
if (m_bMatroska) {
std::list<std::string> pg_sequences;
for (unsigned i = 0; i < m_avFormat->nb_streams; i++) {
- if (m_avFormat->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ if (m_avFormat->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
AVDictionaryEntry *e = av_dict_get(m_avFormat->streams[i]->metadata, "3d-plane", nullptr, AV_DICT_IGNORE_SUFFIX);
if (e && e->value) {
pg_sequences.push_back(std::string(e->value));
@@ -2228,10 +2228,10 @@ const CBaseDemuxer::stream *CLAVFDemuxer::SelectVideoStream()
}
if (!best) { best = check; continue; }
- uint64_t bestPixels = (uint64_t)m_avFormat->streams[best->pid]->codec->width * m_avFormat->streams[best->pid]->codec->height;
- uint64_t checkPixels = (uint64_t)m_avFormat->streams[check->pid]->codec->width * m_avFormat->streams[check->pid]->codec->height;
+ uint64_t bestPixels = (uint64_t)m_avFormat->streams[best->pid]->codecpar->width * m_avFormat->streams[best->pid]->codecpar->height;
+ uint64_t checkPixels = (uint64_t)m_avFormat->streams[check->pid]->codecpar->width * m_avFormat->streams[check->pid]->codecpar->height;
- if (m_avFormat->streams[best->pid]->codec->codec_id == AV_CODEC_ID_NONE && m_avFormat->streams[check->pid]->codec->codec_id != AV_CODEC_ID_NONE) {
+ if (m_avFormat->streams[best->pid]->codecpar->codec_id == AV_CODEC_ID_NONE && m_avFormat->streams[check->pid]->codecpar->codec_id != AV_CODEC_ID_NONE) {
best = check;
continue;
}
@@ -2244,8 +2244,8 @@ const CBaseDemuxer::stream *CLAVFDemuxer::SelectVideoStream()
if (checkPixels > bestPixels) {
best = check;
} else if (m_bRM && checkPixels == bestPixels) {
- int64_t best_rate = m_avFormat->streams[best->pid]->codec->bit_rate;
- int64_t check_rate = m_avFormat->streams[check->pid]->codec->bit_rate;
+ int64_t best_rate = m_avFormat->streams[best->pid]->codecpar->bit_rate;
+ int64_t check_rate = m_avFormat->streams[check->pid]->codecpar->bit_rate;
if (best_rate && check_rate && check_rate > best_rate)
best = check;
}
@@ -2255,10 +2255,10 @@ const CBaseDemuxer::stream *CLAVFDemuxer::SelectVideoStream()
return best;
}
-static int audio_codec_priority(AVCodecContext *codec)
+static int audio_codec_priority(const AVCodecParameters *par)
{
int priority = 0;
- const AVCodecDescriptor *desc = avcodec_descriptor_get(codec->codec_id);
+ const AVCodecDescriptor *desc = avcodec_descriptor_get(par->codec_id);
// lossless codecs have highest priority
if (desc && ((desc->props & (AV_CODEC_PROP_LOSSLESS|AV_CODEC_PROP_LOSSY)) == AV_CODEC_PROP_LOSSLESS)) {
@@ -2266,21 +2266,21 @@ static int audio_codec_priority(AVCodecContext *codec)
} else if (desc && (desc->props & AV_CODEC_PROP_LOSSLESS)) {
priority = 8;
- if (codec->codec_id == AV_CODEC_ID_DTS) {
+ if (par->codec_id == AV_CODEC_ID_DTS) {
priority = 7;
- if (codec->profile == FF_PROFILE_DTS_EXPRESS) {
+ if (par->profile == FF_PROFILE_DTS_EXPRESS) {
priority -= 1;
- } else if (codec->profile == FF_PROFILE_DTS_HD_MA) {
+ } else if (par->profile == FF_PROFILE_DTS_HD_MA) {
priority += 3;
- } else if (codec->profile == FF_PROFILE_DTS_HD_HRA) {
+ } else if (par->profile == FF_PROFILE_DTS_HD_HRA) {
priority += 2;
- } else if (codec->profile >= FF_PROFILE_DTS_ES) {
+ } else if (par->profile >= FF_PROFILE_DTS_ES) {
priority += 1;
}
}
} else {
- switch(codec->codec_id) {
+ switch(par->codec_id) {
case AV_CODEC_ID_EAC3:
priority = 7;
break;
@@ -2295,13 +2295,13 @@ static int audio_codec_priority(AVCodecContext *codec)
}
// WAVE_FORMAT_EXTENSIBLE is multi-channel PCM, which doesn't have a proper tag otherwise
- if(codec->codec_tag == WAVE_FORMAT_EXTENSIBLE) {
+ if(par->codec_tag == WAVE_FORMAT_EXTENSIBLE) {
priority = 10;
}
}
// low priority for S302M with non-pcm content
- if (codec->codec_id == AV_CODEC_ID_S302M && codec->codec_tag != -1)
+ if (par->codec_id == AV_CODEC_ID_S302M && par->codec_tag != -1)
priority = -1;
return priority;
@@ -2385,14 +2385,14 @@ const CBaseDemuxer::stream *CLAVFDemuxer::SelectAudioStream(std::list<std::strin
continue;
// First, check number of channels
- int old_num_chans = old_stream->codec->channels;
- int new_num_chans = new_stream->codec->channels;
+ int old_num_chans = old_stream->codecpar->channels;
+ int new_num_chans = new_stream->codecpar->channels;
if (new_num_chans > old_num_chans) {
best = *sit;
} else if (new_num_chans == old_num_chans) {
// Same number of channels, check codec
- int old_priority = audio_codec_priority(old_stream->codec);
- int new_priority = audio_codec_priority(new_stream->codec);
+ int old_priority = audio_codec_priority(old_stream->codecpar);
+ int new_priority = audio_codec_priority(new_stream->codecpar);
if (new_priority > old_priority) {
best = *sit;
}
@@ -2445,7 +2445,7 @@ const CBaseDemuxer::stream *CLAVFDemuxer::SelectSubtitleStream(std::list<CSubtit
|| ((it->dwFlags & SUBTITLE_FLAG_DEFAULT) && (m_avFormat->streams[sit->pid]->disposition & AV_DISPOSITION_DEFAULT))
|| ((it->dwFlags & SUBTITLE_FLAG_FORCED) && (m_avFormat->streams[sit->pid]->disposition & AV_DISPOSITION_FORCED))
|| ((it->dwFlags & SUBTITLE_FLAG_IMPAIRED) && (m_avFormat->streams[sit->pid]->disposition & (AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_VISUAL_IMPAIRED)))
- || ((it->dwFlags & SUBTITLE_FLAG_PGS) && (m_avFormat->streams[sit->pid]->codec->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE))
+ || ((it->dwFlags & SUBTITLE_FLAG_PGS) && (m_avFormat->streams[sit->pid]->codecpar->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE))
|| ((it->dwFlags & SUBTITLE_FLAG_NORMAL)
&& !(m_avFormat->streams[sit->pid]->disposition & (AV_DISPOSITION_DEFAULT|AV_DISPOSITION_FORCED|AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_VISUAL_IMPAIRED)))) {
std::string streamLanguage = sit->language;
@@ -2476,13 +2476,13 @@ STDMETHODIMP_(DWORD) CLAVFDemuxer::GetStreamFlags(DWORD dwStream)
if (strcmp(m_pszInputFormat, "rawvideo") == 0)
dwFlags |= LAV_STREAM_FLAG_ONLY_DTS;
- if (st->codec->codec_id == AV_CODEC_ID_H264 && (m_bAVI || m_bPMP || (m_bMatroska && (!st->codec->extradata_size || st->codec->extradata[0] != 1)) || (m_bMP4 && st->priv_data && ((MOVStreamContext *)st->priv_data)->ctts_count == 0)))
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264 && (m_bAVI || m_bPMP || (m_bMatroska && (!st->codecpar->extradata_size || st->codecpar->extradata[0] != 1)) || (m_bMP4 && st->priv_data && ((MOVStreamContext *)st->priv_data)->ctts_count == 0)))
dwFlags |= LAV_STREAM_FLAG_ONLY_DTS;
- if (st->codec->codec_id == AV_CODEC_ID_HEVC && m_bAVI)
+ if (st->codecpar->codec_id == AV_CODEC_ID_HEVC && m_bAVI)
dwFlags |= LAV_STREAM_FLAG_ONLY_DTS;
- if (m_bMatroska && (st->codec->codec_id == AV_CODEC_ID_RV30 || st->codec->codec_id == AV_CODEC_ID_RV40))
+ if (m_bMatroska && (st->codecpar->codec_id == AV_CODEC_ID_RV30 || st->codecpar->codec_id == AV_CODEC_ID_RV40))
dwFlags |= LAV_STREAM_FLAG_RV34_MKV;
return dwFlags;
@@ -2493,7 +2493,7 @@ STDMETHODIMP_(int) CLAVFDemuxer::GetPixelFormat(DWORD dwStream)
if (!m_avFormat || dwStream >= m_avFormat->nb_streams)
return AV_PIX_FMT_NONE;
- return m_avFormat->streams[dwStream]->codec->pix_fmt;
+ return m_avFormat->streams[dwStream]->codecpar->format;
}
STDMETHODIMP_(int) CLAVFDemuxer::GetHasBFrames(DWORD dwStream)
@@ -2501,7 +2501,7 @@ STDMETHODIMP_(int) CLAVFDemuxer::GetHasBFrames(DWORD dwStream)
if (!m_avFormat || dwStream >= m_avFormat->nb_streams)
return -1;
- return m_avFormat->streams[dwStream]->codec->has_b_frames;
+ return m_avFormat->streams[dwStream]->codecpar->video_delay;
}
STDMETHODIMP CLAVFDemuxer::GetBSTRMetadata(const char *key, BSTR *pbstrValue, int stream)
diff --git a/demuxer/Demuxers/LAVFStreamInfo.cpp b/demuxer/Demuxers/LAVFStreamInfo.cpp
index cf3fda75..1f29f3c0 100644
--- a/demuxer/Demuxers/LAVFStreamInfo.cpp
+++ b/demuxer/Demuxers/LAVFStreamInfo.cpp
@@ -33,7 +33,7 @@
CLAVFStreamInfo::CLAVFStreamInfo(AVFormatContext *avctx, AVStream *avstream, const char* containerFormat, HRESULT &hr)
: CStreamInfo(), m_containerFormat(containerFormat)
{
- switch(avstream->codec->codec_type) {
+ switch(avstream->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
hr = CreateAudioMediaType(avctx, avstream);
break;
@@ -60,25 +60,25 @@ CLAVFStreamInfo::~CLAVFStreamInfo()
STDMETHODIMP CLAVFStreamInfo::CreateAudioMediaType(AVFormatContext *avctx, AVStream *avstream)
{
// Make sure DTS Express has valid settings
- if (avstream->codec->codec_id == AV_CODEC_ID_DTS && avstream->codec->codec_tag == 0xA2) {
- avstream->codec->channels = avstream->codec->channels ? avstream->codec->channels : 2;
- avstream->codec->channel_layout = avstream->codec->channel_layout ? avstream->codec->channel_layout : av_get_default_channel_layout(avstream->codec->channels);
- avstream->codec->sample_rate = avstream->codec->sample_rate ? avstream->codec->sample_rate : 48000;
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_DTS && avstream->codecpar->codec_tag == 0xA2) {
+ avstream->codecpar->channels = avstream->codecpar->channels ? avstream->codecpar->channels : 2;
+ avstream->codecpar->channel_layout = avstream->codecpar->channel_layout ? avstream->codecpar->channel_layout : av_get_default_channel_layout(avstream->codecpar->channels);
+ avstream->codecpar->sample_rate = avstream->codecpar->sample_rate ? avstream->codecpar->sample_rate : 48000;
}
- if (avstream->codec->codec_tag == 0) {
- avstream->codec->codec_tag = av_codec_get_tag(mp_wav_taglists, avstream->codec->codec_id);
+ if (avstream->codecpar->codec_tag == 0) {
+ avstream->codecpar->codec_tag = av_codec_get_tag(mp_wav_taglists, avstream->codecpar->codec_id);
}
- if (avstream->codec->channels == 0 || avstream->codec->sample_rate == 0 || (is_mpeg_audio(avstream->codec->codec_id) && avstream->codec->frame_size == 0)) {
- if (avstream->codec->codec_id == AV_CODEC_ID_AAC && avstream->codec->bit_rate) {
- if (!avstream->codec->channels) avstream->codec->channels = 2;
- if (!avstream->codec->sample_rate) avstream->codec->sample_rate = 48000;
+ if (avstream->codecpar->channels == 0 || avstream->codecpar->sample_rate == 0 || (is_mpeg_audio(avstream->codecpar->codec_id) && avstream->codecpar->frame_size == 0)) {
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_AAC && avstream->codecpar->bit_rate) {
+ if (!avstream->codecpar->channels) avstream->codecpar->channels = 2;
+ if (!avstream->codecpar->sample_rate) avstream->codecpar->sample_rate = 48000;
} else
return E_FAIL;
}
- CMediaType mtype = g_AudioHelper.initAudioType(avstream->codec->codec_id, avstream->codec->codec_tag, m_containerFormat);
+ CMediaType mtype = g_AudioHelper.initAudioType(avstream->codecpar->codec_id, avstream->codecpar->codec_tag, m_containerFormat);
if(mtype.formattype == FORMAT_WaveFormatEx) {
// Special Logic for the MPEG1 Audio Formats (MP1, MP2)
@@ -88,13 +88,13 @@ STDMETHODIMP CLAVFStreamInfo::CreateAudioMediaType(AVFormatContext *avctx, AVStr
mtype.pbFormat = (BYTE *)g_AudioHelper.CreateWVFMTEX_LPCM(avstream, &mtype.cbFormat);
mtypes.push_back(mtype);
mtype.subtype = MEDIASUBTYPE_HDMV_LPCM_AUDIO;
- } else if ((mtype.subtype == MEDIASUBTYPE_PCM || mtype.subtype == MEDIASUBTYPE_IEEE_FLOAT) && avstream->codec->codec_tag != WAVE_FORMAT_EXTENSIBLE) {
+ } else if ((mtype.subtype == MEDIASUBTYPE_PCM || mtype.subtype == MEDIASUBTYPE_IEEE_FLOAT) && avstream->codecpar->codec_tag != WAVE_FORMAT_EXTENSIBLE) {
// Create raw PCM media type
mtype.pbFormat = (BYTE *)g_AudioHelper.CreateWFMTEX_RAW_PCM(avstream, &mtype.cbFormat, mtype.subtype, &mtype.lSampleSize);
} else {
WAVEFORMATEX *wvfmt = g_AudioHelper.CreateWVFMTEX(avstream, &mtype.cbFormat);
- if (avstream->codec->codec_tag == WAVE_FORMAT_EXTENSIBLE && avstream->codec->extradata_size >= 22) {
+ if (avstream->codecpar->codec_tag == WAVE_FORMAT_EXTENSIBLE && avstream->codecpar->extradata_size >= 22) {
// The WAVEFORMATEXTENSIBLE GUID is not recognized by the audio renderers
// Set the actual subtype as GUID
WAVEFORMATEXTENSIBLE *wvfmtex = (WAVEFORMATEXTENSIBLE *)wvfmt;
@@ -102,28 +102,28 @@ STDMETHODIMP CLAVFStreamInfo::CreateAudioMediaType(AVFormatContext *avctx, AVStr
}
mtype.pbFormat = (BYTE *)wvfmt;
- if (avstream->codec->codec_id == AV_CODEC_ID_FLAC) {
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_FLAC) {
// These are required to block accidental connection to ReClock
wvfmt->nAvgBytesPerSec = (wvfmt->nSamplesPerSec * wvfmt->nChannels * wvfmt->wBitsPerSample) >> 3;
wvfmt->nBlockAlign = 1;
mtype.subtype = MEDIASUBTYPE_FLAC_FRAMED;
mtypes.push_back(mtype);
mtype.subtype = MEDIASUBTYPE_FLAC;
- } else if (avstream->codec->codec_id == AV_CODEC_ID_EAC3) {
+ } else if (avstream->codecpar->codec_id == AV_CODEC_ID_EAC3) {
mtypes.push_back(mtype);
mtype.subtype = MEDIASUBTYPE_DOLBY_DDPLUS_ARCSOFT;
- } else if (avstream->codec->codec_id == AV_CODEC_ID_DTS) {
+ } else if (avstream->codecpar->codec_id == AV_CODEC_ID_DTS) {
wvfmt->wFormatTag = WAVE_FORMAT_DTS2;
- if (avstream->codec->profile >= FF_PROFILE_DTS_HD_HRA) {
+ if (avstream->codecpar->profile >= FF_PROFILE_DTS_HD_HRA) {
mtype.subtype = MEDIASUBTYPE_DTS_HD;
mtypes.push_back(mtype);
}
mtype.subtype = MEDIASUBTYPE_WAVE_DTS;
- } else if (avstream->codec->codec_id == AV_CODEC_ID_TRUEHD) {
+ } else if (avstream->codecpar->codec_id == AV_CODEC_ID_TRUEHD) {
//wvfmt->wFormatTag = (WORD)WAVE_FORMAT_TRUEHD;
mtypes.push_back(mtype);
mtype.subtype = MEDIASUBTYPE_DOLBY_TRUEHD_ARCSOFT;
- } else if (avstream->codec->codec_id == AV_CODEC_ID_AAC) {
+ } else if (avstream->codecpar->codec_id == AV_CODEC_ID_AAC) {
wvfmt->wFormatTag = (WORD)MEDIASUBTYPE_AAC_ADTS.Data1;
CMediaType adtsMtype = mtype;
@@ -137,7 +137,7 @@ STDMETHODIMP CLAVFStreamInfo::CreateAudioMediaType(AVFormatContext *avctx, AVStr
mtype.subtype = MEDIASUBTYPE_AAC;
wvfmt->wFormatTag = (WORD)mtype.subtype.Data1;
- } else if (avstream->codec->codec_id == AV_CODEC_ID_AAC_LATM) {
+ } else if (avstream->codecpar->codec_id == AV_CODEC_ID_AAC_LATM) {
mtypes.push_back(mtype);
mtype.subtype = MEDIASUBTYPE_MPEG_LOAS;
wvfmt->wFormatTag = (WORD)mtype.subtype.Data1;
@@ -176,17 +176,17 @@ STDMETHODIMP CLAVFStreamInfo::CreateAudioMediaType(AVFormatContext *avctx, AVStr
static bool h264_is_annexb(std::string format, AVStream *avstream)
{
- ASSERT(avstream->codec->codec_id == AV_CODEC_ID_H264 || avstream->codec->codec_id == AV_CODEC_ID_H264_MVC);
- if (avstream->codec->extradata_size < 4)
+ ASSERT(avstream->codecpar->codec_id == AV_CODEC_ID_H264 || avstream->codecpar->codec_id == AV_CODEC_ID_H264_MVC);
+ if (avstream->codecpar->extradata_size < 4)
return true;
- if (avstream->codec->extradata[0] == 1)
+ if (avstream->codecpar->extradata[0] == 1)
return false;
if (format == "avi") {
- BYTE *src = avstream->codec->extradata;
+ BYTE *src = avstream->codecpar->extradata;
unsigned startcode = AV_RB32(src);
if (startcode == 0x00000001 || (startcode & 0xffffff00) == 0x00000100)
return true;
- if (avstream->codec->codec_tag == MKTAG('A','V','C','1') || avstream->codec->codec_tag == MKTAG('a','v','c','1'))
+ if (avstream->codecpar->codec_tag == MKTAG('A','V','C','1') || avstream->codecpar->codec_tag == MKTAG('a','v','c','1'))
return false;
}
return true;
@@ -194,10 +194,10 @@ static bool h264_is_annexb(std::string format, AVStream *avstream)
static bool hevc_is_annexb(std::string format, AVStream *avstream)
{
- ASSERT(avstream->codec->codec_id == AV_CODEC_ID_HEVC);
- if (avstream->codec->extradata_size < 23)
+ ASSERT(avstream->codecpar->codec_id == AV_CODEC_ID_HEVC);
+ if (avstream->codecpar->extradata_size < 23)
return true;
- if (avstream->codec->extradata[0] || avstream->codec->extradata[1] || avstream->codec->extradata[2] > 1)
+ if (avstream->codecpar->extradata[0] || avstream->codecpar->extradata[1] || avstream->codecpar->extradata[2] > 1)
return false;
/*if (format == "avi") {
BYTE *src = avstream->codec->extradata;
@@ -210,33 +210,32 @@ static bool hevc_is_annexb(std::string format, AVStream *avstream)
STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStream *avstream)
{
- unsigned int origCodecTag = avstream->codec->codec_tag;
- if (avstream->codec->codec_tag == 0 && avstream->codec->codec_id != AV_CODEC_ID_DVVIDEO) {
- avstream->codec->codec_tag = av_codec_get_tag(mp_bmp_taglists, avstream->codec->codec_id);
+ unsigned int origCodecTag = avstream->codecpar->codec_tag;
+ if (avstream->codecpar->codec_tag == 0 && avstream->codecpar->codec_id != AV_CODEC_ID_DVVIDEO) {
+ avstream->codecpar->codec_tag = av_codec_get_tag(mp_bmp_taglists, avstream->codecpar->codec_id);
}
- if (avstream->codec->codec_id == AV_CODEC_ID_H264_MVC) {
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_H264_MVC) {
// Don't create media types for MVC extension streams, they are handled specially
return S_FALSE;
}
- if (avstream->codec->width == 0 || avstream->codec->height == 0
- || ((avstream->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO || avstream->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) && (avstream->codec->time_base.den == 0 || avstream->codec->time_base.num == 0)))
+ if (avstream->codecpar->width == 0 || avstream->codecpar->height == 0)
return E_FAIL;
- CMediaType mtype = g_VideoHelper.initVideoType(avstream->codec->codec_id, avstream->codec->codec_tag, m_containerFormat);
+ CMediaType mtype = g_VideoHelper.initVideoType(avstream->codecpar->codec_id, avstream->codecpar->codec_tag, m_containerFormat);
mtype.SetTemporalCompression(TRUE);
mtype.SetVariableSize();
// Somewhat hackish to force VIH for AVI content.
// TODO: Figure out why exactly this is required
- if (m_containerFormat == "avi" && avstream->codec->codec_id != AV_CODEC_ID_H264) {
+ if (m_containerFormat == "avi" && avstream->codecpar->codec_id != AV_CODEC_ID_H264) {
mtype.formattype = FORMAT_VideoInfo;
}
// Native MPEG4 in Matroska needs a special formattype
- if (m_containerFormat == "matroska" && avstream->codec->codec_id == AV_CODEC_ID_MPEG4) {
+ if (m_containerFormat == "matroska" && avstream->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
if (AVDictionaryEntry *mkvCodecId = av_dict_get(avstream->metadata, "mkv-codec-id", nullptr, 0)) {
if (strcmp(mkvCodecId->value, "V_MS/VFW/FOURCC") != 0)
mtype.formattype = FORMAT_MPEG2Video;
@@ -245,7 +244,7 @@ STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStr
// If we need aspect info, we switch to VIH2
AVRational r = avstream->sample_aspect_ratio;
- AVRational rc = avstream->codec->sample_aspect_ratio;
+ AVRational rc = avstream->codecpar->sample_aspect_ratio;
if (mtype.formattype == FORMAT_VideoInfo && ((r.den > 0 && r.num > 0 && (r.den > 1 || r.num > 1)) || (rc.den > 0 && rc.num > 0 && (rc.den > 1 || rc.num > 1)))) {
mtype.formattype = FORMAT_VideoInfo2;
}
@@ -276,7 +275,7 @@ STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStr
} else if (mtype.formattype == FORMAT_MPEG2Video) {
mtype.pbFormat = (BYTE *)g_VideoHelper.CreateMPEG2VI(avstream, &mtype.cbFormat, m_containerFormat, FALSE);
MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)mtype.pbFormat;
- if (avstream->codec->codec_id == AV_CODEC_ID_H264) {
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_H264) {
if (h264_is_annexb(m_containerFormat, avstream)) {
mtype.subtype = MEDIASUBTYPE_H264;
} else {
@@ -296,7 +295,7 @@ STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStr
MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)mtype.pbFormat;
mp2vi->hdr.bmiHeader.biCompression = mtype.subtype.Data1;
}
- } else if (avstream->codec->codec_id == AV_CODEC_ID_HEVC) {
+ } else if (avstream->codecpar->codec_id == AV_CODEC_ID_HEVC) {
if (hevc_is_annexb(m_containerFormat, avstream)) {
mtype.subtype = MEDIASUBTYPE_HEVC;
} else {
@@ -307,7 +306,7 @@ STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStr
}
// Detect MVC extensions and adjust the type appropriately
- if (avstream->codec->codec_id == AV_CODEC_ID_H264) {
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_H264) {
if (h264_is_annexb(m_containerFormat, avstream)) {
if (m_containerFormat == "mpegts") {
int nBaseStream = -1, nExtensionStream = -1;
@@ -315,23 +314,23 @@ STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStr
CMediaType mvcType = mtypes.front();
AVStream *mvcStream = avctx->streams[nExtensionStream];
- MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)mvcType.ReallocFormatBuffer(sizeof(MPEG2VIDEOINFO) + avstream->codec->extradata_size + mvcStream->codec->extradata_size);
+ MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)mvcType.ReallocFormatBuffer(sizeof(MPEG2VIDEOINFO) + avstream->codecpar->extradata_size + mvcStream->codecpar->extradata_size);
// Append the mvc subset data to the base view extradata
- memcpy((BYTE *)&mp2vi->dwSequenceHeader[0] + avstream->codec->extradata_size, mvcStream->codec->extradata, mvcStream->codec->extradata_size);
- mp2vi->cbSequenceHeader = avstream->codec->extradata_size + mvcStream->codec->extradata_size;
+ memcpy((BYTE *)&mp2vi->dwSequenceHeader[0] + avstream->codecpar->extradata_size, mvcStream->codecpar->extradata, mvcStream->codecpar->extradata_size);
+ mp2vi->cbSequenceHeader = avstream->codecpar->extradata_size + mvcStream->codecpar->extradata_size;
mvcType.cbFormat = SIZE_MPEG2VIDEOINFO(mp2vi);
mvcType.subtype = MEDIASUBTYPE_AMVC;
mp2vi->hdr.bmiHeader.biCompression = mvcType.subtype.Data1;
CH264Nalu nalParser;
- nalParser.SetBuffer(mvcStream->codec->extradata, mvcStream->codec->extradata_size, 0);
+ nalParser.SetBuffer(mvcStream->codecpar->extradata, mvcStream->codecpar->extradata_size, 0);
while (nalParser.ReadNext()) {
if (nalParser.GetType() == 15) { // Subset SPS
const BYTE *pData = nalParser.GetDataBuffer();
- mp2vi->dwProfile = avstream->codec->profile = pData[1];
- mp2vi->dwLevel = avstream->codec->level = pData[3];
+ mp2vi->dwProfile = avstream->codecpar->profile = pData[1];
+ mp2vi->dwLevel = avstream->codecpar->level = pData[3];
break;
}
}
@@ -342,8 +341,8 @@ STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStr
} else {
CMediaType mvcType = mtype;
- MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)mvcType.ReallocFormatBuffer(sizeof(MPEG2VIDEOINFO) + avstream->codec->extradata_size);
- HRESULT hr = g_VideoHelper.ProcessH264MVCExtradata(avstream->codec->extradata, avstream->codec->extradata_size, mp2vi);
+ MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)mvcType.ReallocFormatBuffer(sizeof(MPEG2VIDEOINFO) + avstream->codecpar->extradata_size);
+ HRESULT hr = g_VideoHelper.ProcessH264MVCExtradata(avstream->codecpar->extradata, avstream->codecpar->extradata_size, mp2vi);
if (hr == S_OK) {
mvcType.cbFormat = SIZE_MPEG2VIDEOINFO(mp2vi);
mvcType.subtype = MEDIASUBTYPE_MVC1;
@@ -352,21 +351,21 @@ STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStr
// update stream profile/level appropriately
if (mp2vi->dwProfile != 0)
- avstream->codec->profile = mp2vi->dwProfile;
+ avstream->codecpar->profile = mp2vi->dwProfile;
if (mp2vi->dwLevel != 0)
- avstream->codec->level = mp2vi->dwLevel;
+ avstream->codecpar->level = mp2vi->dwLevel;
}
}
}
- if (avstream->codec->codec_id == AV_CODEC_ID_RAWVIDEO) {
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
BITMAPINFOHEADER *pBMI = nullptr;
videoFormatTypeHandler(mtype.pbFormat, &mtype.formattype, &pBMI, nullptr, nullptr, nullptr);
mtype.bFixedSizeSamples = TRUE;
mtype.bTemporalCompression = FALSE;
mtype.lSampleSize = pBMI->biSizeImage;
- if (!avstream->codec->codec_tag || avstream->codec->codec_tag == MKTAG('r','a','w',' ')) {
- switch (avstream->codec->pix_fmt) {
+ if (!avstream->codecpar->codec_tag || avstream->codecpar->codec_tag == MKTAG('r','a','w',' ')) {
+ switch (avstream->codecpar->format) {
case AV_PIX_FMT_BGRA:
mtype.subtype = MEDIASUBTYPE_ARGB32;
mtypes.push_back(mtype);
@@ -379,7 +378,7 @@ STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStr
DbgLog((LOG_TRACE, 10, L"::CreateVideoMediaType(): Unsupported raw video pixel format"));
}
} else {
- switch (avstream->codec->codec_tag) {
+ switch (avstream->codecpar->codec_tag) {
case MKTAG('B','G','R','A'):
{
pBMI->biHeight = -pBMI->biHeight;
@@ -403,17 +402,17 @@ STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStr
ASSERT(0);
}
extrasize = mtype.cbFormat - hdrsize;
- mtype.ReallocFormatBuffer((ULONG)(hdrsize + extrasize + sizeof(avstream->codec->pix_fmt)));
+ mtype.ReallocFormatBuffer((ULONG)(hdrsize + extrasize + sizeof(avstream->codecpar->format)));
if (extrasize) {
- memmove(mtype.pbFormat + hdrsize + sizeof(avstream->codec->pix_fmt), mtype.pbFormat + hdrsize, extrasize);
+ memmove(mtype.pbFormat + hdrsize + sizeof(avstream->codecpar->format), mtype.pbFormat + hdrsize, extrasize);
}
- *(int *)(mtype.pbFormat + hdrsize) = avstream->codec->pix_fmt;
+ *(int *)(mtype.pbFormat + hdrsize) = avstream->codecpar->format;
videoFormatTypeHandler(mtype.pbFormat, &mtype.formattype, &pBMI, nullptr, nullptr, nullptr);
- pBMI->biSize = (DWORD)(sizeof(BITMAPINFOHEADER) + sizeof(avstream->codec->pix_fmt) + extrasize);
+ pBMI->biSize = (DWORD)(sizeof(BITMAPINFOHEADER) + sizeof(avstream->codecpar->format) + extrasize);
mtypes.push_back(mtype);
}
- if (avstream->codec->codec_id == AV_CODEC_ID_MJPEG) {
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_MJPEG) {
BITMAPINFOHEADER *pBMI = nullptr;
videoFormatTypeHandler(mtype.pbFormat, &mtype.formattype, &pBMI, nullptr, nullptr, nullptr);
@@ -469,24 +468,24 @@ static std::string GetDefaultVOBSubHeader(int w, int h)
STDMETHODIMP CLAVFStreamInfo::CreateSubtitleMediaType(AVFormatContext *avctx, AVStream *avstream)
{
// Skip teletext
- if (avstream->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
return E_FAIL;
}
CMediaType mtype;
mtype.majortype = MEDIATYPE_Subtitle;
mtype.formattype = FORMAT_SubtitleInfo;
- int extra = avstream->codec->extradata_size;
+ int extra = avstream->codecpar->extradata_size;
// parse flags from mov tx3g atom
- if (avstream->codec->codec_id == AV_CODEC_ID_MOV_TEXT && avstream->codec->codec_tag == MKTAG('t', 'x', '3', 'g') && extra >= 4)
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_MOV_TEXT && avstream->codecpar->codec_tag == MKTAG('t', 'x', '3', 'g') && extra >= 4)
{
- uint32_t flags = AV_RB32(avstream->codec->extradata);
+ uint32_t flags = AV_RB32(avstream->codecpar->extradata);
if (flags & 0x80000000)
avstream->disposition |= AV_DISPOSITION_FORCED;
}
- if (avstream->codec->codec_id == AV_CODEC_ID_MOV_TEXT || avstream->codec->codec_id == AV_CODEC_ID_TEXT || avstream->codec->codec_id == AV_CODEC_ID_SUBRIP) {
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_MOV_TEXT || avstream->codecpar->codec_id == AV_CODEC_ID_TEXT || avstream->codecpar->codec_id == AV_CODEC_ID_SUBRIP) {
extra = 0;
}
@@ -515,21 +514,21 @@ STDMETHODIMP CLAVFStreamInfo::CreateSubtitleMediaType(AVFormatContext *avctx, AV
// Find first video stream
AVStream *vidStream = nullptr;
for (unsigned i = 0; i < avctx->nb_streams; i++) {
- if (avctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (avctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
vidStream = avctx->streams[i];
break;
}
}
// Extradata
- if (m_containerFormat == "mp4" && avstream->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
- std::string strVobSubHeader = CreateVOBSubHeaderFromMP4(vidStream ? vidStream->codec->width : 720, vidStream ? vidStream->codec->height : 576, (MOVStreamContext *)avstream->priv_data, (char*)avstream->codec->extradata, extra);
+ if (m_containerFormat == "mp4" && avstream->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
+ std::string strVobSubHeader = CreateVOBSubHeaderFromMP4(vidStream ? vidStream->codecpar->width : 720, vidStream ? vidStream->codecpar->height : 576, (MOVStreamContext *)avstream->priv_data, (char*)avstream->codecpar->extradata, extra);
size_t len = strVobSubHeader.length();
mtype.ReallocFormatBuffer((ULONG)(sizeof(SUBTITLEINFO) + len));
memcpy(mtype.pbFormat + sizeof(SUBTITLEINFO), strVobSubHeader.c_str(), len);
- } else if (m_containerFormat == "mpeg" && avstream->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
+ } else if (m_containerFormat == "mpeg" && avstream->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
// And a VobSub type
- std::string strVobSubHeader = GetDefaultVOBSubHeader(vidStream ? vidStream->codec->width : 720, vidStream ? vidStream->codec->height : 576);
+ std::string strVobSubHeader = GetDefaultVOBSubHeader(vidStream ? vidStream->codecpar->width : 720, vidStream ? vidStream->codecpar->height : 576);
size_t len = strVobSubHeader.length();
mtype.ReallocFormatBuffer((ULONG)(sizeof(SUBTITLEINFO) + len));
memcpy(mtype.pbFormat + sizeof(SUBTITLEINFO), strVobSubHeader.c_str(), len);
@@ -543,24 +542,24 @@ STDMETHODIMP CLAVFStreamInfo::CreateSubtitleMediaType(AVFormatContext *avctx, AV
dvdmtype.formattype = FORMAT_MPEG2_VIDEO;
MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)dvdmtype.AllocFormatBuffer(sizeof(MPEG2VIDEOINFO));
ZeroMemory(mp2vi, sizeof(MPEG2VIDEOINFO));
- mp2vi->hdr.bmiHeader.biWidth = vidStream ? vidStream->codec->width : 720;
- mp2vi->hdr.bmiHeader.biHeight = vidStream ? vidStream->codec->height : 576;
+ mp2vi->hdr.bmiHeader.biWidth = vidStream ? vidStream->codecpar->width : 720;
+ mp2vi->hdr.bmiHeader.biHeight = vidStream ? vidStream->codecpar->height : 576;
mtypes.push_back(dvdmtype);
return S_OK;
} else {
- memcpy(mtype.pbFormat + sizeof(SUBTITLEINFO), avstream->codec->extradata, extra);
+ memcpy(mtype.pbFormat + sizeof(SUBTITLEINFO), avstream->codecpar->extradata, extra);
}
- mtype.subtype = avstream->codec->codec_id == AV_CODEC_ID_TEXT ? MEDIASUBTYPE_UTF8 :
- avstream->codec->codec_id == AV_CODEC_ID_SRT ? MEDIASUBTYPE_UTF8 : /* SRT is essentially SUBRIP with inband timing information, parsing needed */
- avstream->codec->codec_id == AV_CODEC_ID_SUBRIP ? MEDIASUBTYPE_UTF8 :
- avstream->codec->codec_id == AV_CODEC_ID_MOV_TEXT ? MEDIASUBTYPE_UTF8 :
- avstream->codec->codec_id == AV_CODEC_ID_ASS ? MEDIASUBTYPE_ASS :
- avstream->codec->codec_id == AV_CODEC_ID_SSA ? MEDIASUBTYPE_ASS :
- avstream->codec->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE ? MEDIASUBTYPE_HDMVSUB :
- avstream->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE ? MEDIASUBTYPE_VOBSUB :
- avstream->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE ? MEDIASUBTYPE_DVB_SUBTITLES :
+ mtype.subtype = avstream->codecpar->codec_id == AV_CODEC_ID_TEXT ? MEDIASUBTYPE_UTF8 :
+ avstream->codecpar->codec_id == AV_CODEC_ID_SRT ? MEDIASUBTYPE_UTF8 : /* SRT is essentially SUBRIP with inband timing information, parsing needed */
+ avstream->codecpar->codec_id == AV_CODEC_ID_SUBRIP ? MEDIASUBTYPE_UTF8 :
+ avstream->codecpar->codec_id == AV_CODEC_ID_MOV_TEXT ? MEDIASUBTYPE_UTF8 :
+ avstream->codecpar->codec_id == AV_CODEC_ID_ASS ? MEDIASUBTYPE_ASS :
+ avstream->codecpar->codec_id == AV_CODEC_ID_SSA ? MEDIASUBTYPE_ASS :
+ avstream->codecpar->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE ? MEDIASUBTYPE_HDMVSUB :
+ avstream->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE ? MEDIASUBTYPE_VOBSUB :
+ avstream->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE ? MEDIASUBTYPE_DVB_SUBTITLES :
MEDIASUBTYPE_NULL;
mtypes.push_back(mtype);
diff --git a/demuxer/Demuxers/LAVFUtils.cpp b/demuxer/Demuxers/LAVFUtils.cpp
index 17a12407..3d3ac349 100644
--- a/demuxer/Demuxers/LAVFUtils.cpp
+++ b/demuxer/Demuxers/LAVFUtils.cpp
@@ -26,21 +26,21 @@ extern "C" {
#include <sstream>
-static int64_t get_bit_rate(AVCodecContext *ctx)
+static int64_t get_bit_rate(const AVCodecParameters *par)
{
int64_t bit_rate;
int bits_per_sample;
- switch(ctx->codec_type) {
+ switch(par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
case AVMEDIA_TYPE_DATA:
case AVMEDIA_TYPE_SUBTITLE:
case AVMEDIA_TYPE_ATTACHMENT:
- bit_rate = ctx->bit_rate;
+ bit_rate = par->bit_rate;
break;
case AVMEDIA_TYPE_AUDIO:
- bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
- bit_rate = ctx->bit_rate ? ctx->bit_rate : ctx->sample_rate * ctx->channels * bits_per_sample;
+ bits_per_sample = av_get_bits_per_sample(par->codec_id);
+ bit_rate = par->bit_rate ? par->bit_rate : par->sample_rate * par->channels * bits_per_sample;
break;
default:
bit_rate = 0;
@@ -95,14 +95,14 @@ static std::string tolower(const char *str) {
return ret;
}
-std::string get_codec_name(AVCodecContext *pCodecCtx)
+std::string get_codec_name(const AVCodecParameters *par)
{
- AVCodecID id = pCodecCtx->codec_id;
+ AVCodecID id = par->codec_id;
// Grab the codec
const AVCodec *p = avcodec_find_decoder(id);
const AVCodecDescriptor *desc = avcodec_descriptor_get(id);
- const char *profile = avcodec_profile_name(id, pCodecCtx->profile);
+ const char *profile = avcodec_profile_name(id, par->profile);
std::ostringstream codec_name;
@@ -115,21 +115,21 @@ std::string get_codec_name(AVCodecContext *pCodecCtx)
}
}
- if (id == AV_CODEC_ID_DTS && pCodecCtx->codec_tag == 0xA2) {
+ if (id == AV_CODEC_ID_DTS && par->codec_tag == 0xA2) {
profile = "DTS Express";
}
if (id == AV_CODEC_ID_H264 && profile) {
codec_name << nice_name << " " << tolower(profile);
- if (pCodecCtx->level && pCodecCtx->level != FF_LEVEL_UNKNOWN && pCodecCtx->level < 1000) {
+ if (par->level && par->level != FF_LEVEL_UNKNOWN && par->level < 1000) {
char l_buf[5];
- sprintf_s(l_buf, "%.1f", pCodecCtx->level / 10.0);
+ sprintf_s(l_buf, "%.1f", par->level / 10.0);
codec_name << " L" << l_buf;
}
} else if (id == AV_CODEC_ID_VC1 && profile) {
codec_name << nice_name << " " << tolower(profile);
- if (pCodecCtx->level != FF_LEVEL_UNKNOWN) {
- codec_name << " L" << pCodecCtx->level;
+ if (par->level != FF_LEVEL_UNKNOWN) {
+ codec_name << " L" << par->level;
}
} else if (id == AV_CODEC_ID_DTS && profile) {
codec_name << tolower(profile);
@@ -150,9 +150,9 @@ std::string get_codec_name(AVCodecContext *pCodecCtx)
} else {
/* output avi tags */
char buf[32];
- av_get_codec_tag_string(buf, sizeof(buf), pCodecCtx->codec_tag);
+ av_get_codec_tag_string(buf, sizeof(buf), par->codec_tag);
codec_name << buf;
- sprintf_s(buf, "0x%04X", pCodecCtx->codec_tag);
+ sprintf_s(buf, "0x%04X", par->codec_tag);
codec_name << " / " << buf;
}
return codec_name.str();
@@ -179,8 +179,8 @@ static std::string format_flags(int flags){
return out.str();
}
-static bool show_sample_fmt(AVCodecContext *ctx) {
- AVCodecID codec_id = ctx->codec_id;
+static bool show_sample_fmt(const AVCodecParameters *par) {
+ AVCodecID codec_id = par->codec_id;
// PCM Codecs
if (codec_id >= 0x10000 && codec_id < 0x12000) {
@@ -198,13 +198,13 @@ static bool show_sample_fmt(AVCodecContext *ctx) {
}
// Lossless DTS
- if (codec_id == AV_CODEC_ID_DTS && ctx->profile == FF_PROFILE_DTS_HD_MA)
+ if (codec_id == AV_CODEC_ID_DTS && par->profile == FF_PROFILE_DTS_HD_MA)
return true;
return false;
}
-const char * lavf_get_stream_title(AVStream * pStream)
+const char * lavf_get_stream_title(const AVStream * pStream)
{
char *title = nullptr;
if (AVDictionaryEntry *dictEntry = av_dict_get(pStream->metadata, "title", nullptr, 0)) {
@@ -218,11 +218,11 @@ const char * lavf_get_stream_title(AVStream * pStream)
return title;
}
-std::string lavf_get_stream_description(AVStream *pStream)
+std::string lavf_get_stream_description(const AVStream *pStream)
{
- AVCodecContext *enc = pStream->codec;
+ AVCodecParameters *par = pStream->codecpar;
- std::string codec_name = get_codec_name(enc);
+ std::string codec_name = get_codec_name(par);
const char *lang = get_stream_language(pStream);
std::string sLanguage;
@@ -240,10 +240,10 @@ std::string lavf_get_stream_description(AVStream *pStream)
if (title && strlen(title) == 0)
title = nullptr;
- int64_t bitrate = get_bit_rate(enc);
+ int64_t bitrate = get_bit_rate(par);
std::ostringstream buf;
- switch(enc->codec_type) {
+ switch(par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
buf << "V: ";
// Title/Language
@@ -258,18 +258,18 @@ std::string lavf_get_stream_description(AVStream *pStream)
// Codec
buf << codec_name;
// Pixel Format
- if (const char *pix_fmt = av_get_pix_fmt_name(enc->pix_fmt)) {
+ if (const char *pix_fmt = av_get_pix_fmt_name((AVPixelFormat)par->format)) {
buf << ", " << pix_fmt;
}
// Dimensions
- if (enc->width) {
- buf << ", " << enc->width << "x" << enc->height;
+ if (par->width) {
+ buf << ", " << par->width << "x" << par->height;
}
// Bitrate
if (bitrate > 0) {
buf << ", " << (bitrate / 1000) << " kb/s";
}
- if (enc->codec_id == AV_CODEC_ID_H264 && enc->profile == FF_PROFILE_H264_STEREO_HIGH) {
+ if (par->codec_id == AV_CODEC_ID_H264 && par->profile == FF_PROFILE_H264_STEREO_HIGH) {
AVDictionaryEntry *entry = av_dict_get(pStream->metadata, "stereo_mode", nullptr, 0);
if (entry && strcmp(entry->value, "mvc_lr") == 0)
buf << ", lr";
@@ -296,23 +296,23 @@ std::string lavf_get_stream_description(AVStream *pStream)
// Codec
buf << codec_name;
// Sample Rate
- if (enc->sample_rate) {
- buf << ", " << enc->sample_rate << " Hz";
+ if (par->sample_rate) {
+ buf << ", " << par->sample_rate << " Hz";
}
- if (enc->channels) {
+ if (par->channels) {
// Get channel layout
char channel[32];
- av_get_channel_layout_string(channel, 32, enc->channels, enc->channel_layout);
+ av_get_channel_layout_string(channel, 32, par->channels, par->channel_layout);
buf << ", " << channel;
}
// Sample Format
- if (show_sample_fmt(enc) && get_bits_per_sample(enc, true)) {
- if (enc->sample_fmt == AV_SAMPLE_FMT_FLT || enc->sample_fmt == AV_SAMPLE_FMT_DBL) {
+ if (show_sample_fmt(par) && get_bits_per_sample(par, true)) {
+ if (par->format == AV_SAMPLE_FMT_FLT || par->format == AV_SAMPLE_FMT_DBL) {
buf << ", fp";
} else {
buf << ", s";
}
- buf << get_bits_per_sample(enc, true);
+ buf << get_bits_per_sample(par, true);
}
// Bitrate
if (bitrate > 0) {
@@ -360,7 +360,7 @@ bool GetH264MVCStreamIndices(AVFormatContext *fmt, int *nBaseIndex, int *nExtens
for (unsigned int i = 0; i < fmt->nb_streams; i++) {
AVStream *st = fmt->streams[i];
- if (st->codec->codec_id == AV_CODEC_ID_H264_MVC && st->codec->extradata_size > 0) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264_MVC && st->codecpar->extradata_size > 0) {
if (*nExtensionIndex == -1)
*nExtensionIndex = i;
else {
@@ -368,8 +368,8 @@ bool GetH264MVCStreamIndices(AVFormatContext *fmt, int *nBaseIndex, int *nExtens
bResult = false;
}
}
- else if (st->codec->codec_id == AV_CODEC_ID_H264) {
- if ((st->codec->width == 1920 && st->codec->height == 1080) || (st->codec->width == 1280 && st->codec->height == 720))
+ else if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
+ if ((st->codecpar->width == 1920 && st->codecpar->height == 1080) || (st->codecpar->width == 1280 && st->codecpar->height == 720))
{
if (*nBaseIndex == -1)
*nBaseIndex = i;
diff --git a/demuxer/Demuxers/LAVFUtils.h b/demuxer/Demuxers/LAVFUtils.h
index 78ed5807..889e6a2b 100644
--- a/demuxer/Demuxers/LAVFUtils.h
+++ b/demuxer/Demuxers/LAVFUtils.h
@@ -27,23 +27,23 @@ struct FormatMapping {
};
const char *get_stream_language(const AVStream *pStream);
-std::string get_codec_name(AVCodecContext *pCodecCtx);
-const char * lavf_get_stream_title(AVStream * pStream);
-std::string lavf_get_stream_description(AVStream *pStream);
+std::string get_codec_name(const AVCodecParameters *par);
+const char * lavf_get_stream_title(const AVStream * pStream);
+std::string lavf_get_stream_description(const AVStream *pStream);
#define LAVF_DISPOSITION_SUB_STREAM 0x10000
#define LAVF_DISPOSITION_SECONDARY_AUDIO 0x20000
-inline int get_bits_per_sample(AVCodecContext *ctx, bool bRaw = false)
+inline int get_bits_per_sample(AVCodecParameters *par, bool bRaw = false)
{
- int bits = av_get_bits_per_sample(ctx->codec_id);
+ int bits = av_get_bits_per_sample(par->codec_id);
if (!bits || bRaw) {
- bits = ctx->bits_per_coded_sample;
+ bits = par->bits_per_coded_sample;
if(!bits || bRaw) {
- if ((ctx->sample_fmt == AV_SAMPLE_FMT_S32 || ctx->sample_fmt == AV_SAMPLE_FMT_S32P) && ctx->bits_per_raw_sample) {
- bits = ctx->bits_per_raw_sample;
+ if ((par->format == AV_SAMPLE_FMT_S32 || par->format == AV_SAMPLE_FMT_S32P) && par->bits_per_raw_sample) {
+ bits = par->bits_per_raw_sample;
} else {
- bits = av_get_bytes_per_sample(ctx->sample_fmt) << 3;
+ bits = av_get_bytes_per_sample((AVSampleFormat)par->format) << 3;
}
}
}
diff --git a/demuxer/Demuxers/LAVFVideoHelper.cpp b/demuxer/Demuxers/LAVFVideoHelper.cpp
index 2a4dcc3a..51f0e84f 100644
--- a/demuxer/Demuxers/LAVFVideoHelper.cpp
+++ b/demuxer/Demuxers/LAVFVideoHelper.cpp
@@ -156,7 +156,7 @@ size_t avc_parse_annexb(BYTE *extra, int extrasize, BYTE *dst)
VIDEOINFOHEADER *CLAVFVideoHelper::CreateVIH(const AVStream* avstream, ULONG *size, std::string container)
{
- VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER*)CoTaskMemAlloc(ULONG(sizeof(VIDEOINFOHEADER) + avstream->codec->extradata_size));
+ VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER*)CoTaskMemAlloc(ULONG(sizeof(VIDEOINFOHEADER) + avstream->codecpar->extradata_size));
if (!pvi) return nullptr;
memset(pvi, 0, sizeof(VIDEOINFOHEADER));
// Get the frame rate
@@ -167,9 +167,12 @@ VIDEOINFOHEADER *CLAVFVideoHelper::CreateVIH(const AVStream* avstream, ULONG *si
if (avstream->avg_frame_rate.den > 0 && avstream->avg_frame_rate.num > 0) {
avg_avg = av_rescale(DSHOW_TIME_BASE, avstream->avg_frame_rate.den, avstream->avg_frame_rate.num);
}
+#pragma warning(push)
+#pragma warning(disable: 4996)
if (avstream->codec->time_base.den > 0 && avstream->codec->time_base.num > 0 && avstream->codec->ticks_per_frame > 0) {
tb_avg = av_rescale(DSHOW_TIME_BASE, avstream->codec->time_base.num * avstream->codec->ticks_per_frame, avstream->codec->time_base.den);
}
+#pragma warning(pop)
DbgLog((LOG_TRACE, 10, L"CreateVIH: r_avg: %I64d, avg_avg: %I64d, tb_avg: %I64d", r_avg, avg_avg, tb_avg));
if (r_avg >= MIN_TIME_PER_FRAME && r_avg <= MAX_TIME_PER_FRAME)
@@ -181,7 +184,7 @@ VIDEOINFOHEADER *CLAVFVideoHelper::CreateVIH(const AVStream* avstream, ULONG *si
else
pvi->AvgTimePerFrame = r_avg;
- if (container == "matroska" && r_avg && tb_avg && (avstream->codec->codec_id == AV_CODEC_ID_H264 || avstream->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO)) {
+ if (container == "matroska" && r_avg && tb_avg && (avstream->codecpar->codec_id == AV_CODEC_ID_H264 || avstream->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)) {
float factor = (float)r_avg / (float)tb_avg;
if ((factor > 0.4 && factor < 0.6) || (factor > 1.9 && factor < 2.1)) {
pvi->AvgTimePerFrame = tb_avg;
@@ -189,28 +192,28 @@ VIDEOINFOHEADER *CLAVFVideoHelper::CreateVIH(const AVStream* avstream, ULONG *si
}
pvi->dwBitErrorRate = 0;
- pvi->dwBitRate = (DWORD)avstream->codec->bit_rate;
+ pvi->dwBitRate = (DWORD)avstream->codecpar->bit_rate;
RECT empty_tagrect = {0,0,0,0};
pvi->rcSource = empty_tagrect;//Some codecs like wmv are setting that value to the video current value
pvi->rcTarget = empty_tagrect;
- pvi->rcTarget.right = pvi->rcSource.right = avstream->codec->width;
- pvi->rcTarget.bottom = pvi->rcSource.bottom = avstream->codec->height;
+ pvi->rcTarget.right = pvi->rcSource.right = avstream->codecpar->width;
+ pvi->rcTarget.bottom = pvi->rcSource.bottom = avstream->codecpar->height;
- memcpy((BYTE*)&pvi->bmiHeader + sizeof(BITMAPINFOHEADER), avstream->codec->extradata, avstream->codec->extradata_size);
- pvi->bmiHeader.biSize = ULONG(sizeof(BITMAPINFOHEADER) + avstream->codec->extradata_size);
+ memcpy((BYTE*)&pvi->bmiHeader + sizeof(BITMAPINFOHEADER), avstream->codecpar->extradata, avstream->codecpar->extradata_size);
+ pvi->bmiHeader.biSize = ULONG(sizeof(BITMAPINFOHEADER) + avstream->codecpar->extradata_size);
- pvi->bmiHeader.biWidth = avstream->codec->width;
- pvi->bmiHeader.biHeight = avstream->codec->height;
- pvi->bmiHeader.biBitCount = avstream->codec->bits_per_coded_sample;
+ pvi->bmiHeader.biWidth = avstream->codecpar->width;
+ pvi->bmiHeader.biHeight = avstream->codecpar->height;
+ pvi->bmiHeader.biBitCount = avstream->codecpar->bits_per_coded_sample;
// Validate biBitCount is set to something useful
- if ((pvi->bmiHeader.biBitCount == 0 || avstream->codec->codec_id == AV_CODEC_ID_RAWVIDEO) && avstream->codec->pix_fmt != AV_PIX_FMT_NONE) {
- const AVPixFmtDescriptor *pixdecs = av_pix_fmt_desc_get(avstream->codec->pix_fmt);
+ if ((pvi->bmiHeader.biBitCount == 0 || avstream->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) && avstream->codecpar->format != AV_PIX_FMT_NONE) {
+ const AVPixFmtDescriptor *pixdecs = av_pix_fmt_desc_get((AVPixelFormat)avstream->codecpar->format);
if (pixdecs)
pvi->bmiHeader.biBitCount = av_get_bits_per_pixel(pixdecs);
}
pvi->bmiHeader.biSizeImage = DIBSIZE(pvi->bmiHeader); // Calculating this value doesn't really make alot of sense, but apparently some decoders freak out if its 0
- pvi->bmiHeader.biCompression = avstream->codec->codec_tag;
+ pvi->bmiHeader.biCompression = avstream->codecpar->codec_tag;
//TOFIX The bitplanes is depending on the subtype
pvi->bmiHeader.biPlanes = 1;
pvi->bmiHeader.biClrUsed = 0;
@@ -218,7 +221,7 @@ VIDEOINFOHEADER *CLAVFVideoHelper::CreateVIH(const AVStream* avstream, ULONG *si
pvi->bmiHeader.biYPelsPerMeter = 0;
pvi->bmiHeader.biXPelsPerMeter = 0;
- *size = sizeof(VIDEOINFOHEADER) + avstream->codec->extradata_size;
+ *size = sizeof(VIDEOINFOHEADER) + avstream->codecpar->extradata_size;
return pvi;
}
@@ -230,10 +233,10 @@ VIDEOINFOHEADER2 *CLAVFVideoHelper::CreateVIH2(const AVStream* avstream, ULONG *
int extra = 0;
BYTE *extradata = nullptr;
BOOL bZeroPad = FALSE;
- if (avstream->codec->codec_id == AV_CODEC_ID_VC1 && avstream->codec->extradata_size) {
+ if (avstream->codecpar->codec_id == AV_CODEC_ID_VC1 && avstream->codecpar->extradata_size) {
int i = 0;
- for (i = 0; i < (avstream->codec->extradata_size-4); i++) {
- uint32_t code = AV_RB32(avstream->codec->extradata + i);
+ for (i = 0; i < (avstream->codecpar->extradata_size-4); i++) {
+ uint32_t code = AV_RB32(avstream->codecpar->extradata + i);
if (IS_VC1_MARKER(code))
break;
}
@@ -248,14 +251,14 @@ VIDEOINFOHEADER2 *CLAVFVideoHelper::CreateVIH2(const AVStream* avstream, ULONG *
VIDEOINFOHEADER *vih = CreateVIH(avstream, size, container);
if (!vih) return nullptr;
- if(avstream->codec->extradata_size > 0) {
- extra = avstream->codec->extradata_size;
+ if(avstream->codecpar->extradata_size > 0) {
+ extra = avstream->codecpar->extradata_size;
//increase extra size by one, because VIH2 requires one 0 byte between header and extra data
if (bZeroPad) {
extra++;
}
- extradata = avstream->codec->extradata;
+ extradata = avstream->codecpar->extradata;
}
VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)CoTaskMemAlloc(sizeof(VIDEOINFOHEADER2) + extra);
@@ -270,7 +273,7 @@ VIDEOINFOHEADER2 *CLAVFVideoHelper::CreateVIH2(const AVStream* avstream, ULONG *
// Calculate aspect ratio
AVRational r = avstream->sample_aspect_ratio;
- AVRational rc = avstream->codec->sample_aspect_ratio;
+ AVRational rc = avstream->codecpar->sample_aspect_ratio;
int num = vih->bmiHeader.biWidth, den = vih->bmiHeader.biHeight;
if (r.den > 0 && r.num > 0) {
av_reduce(&num, &den, (int64_t)r.num * num, (int64_t)r.den * den, INT_MAX);
@@ -317,9 +320,9 @@ MPEG1VIDEOINFO *CLAVFVideoHelper::CreateMPEG1VI(const AVStream* avstream, ULONG
VIDEOINFOHEADER *vih = CreateVIH(avstream, size, container);
if (!vih) return nullptr;
- if(avstream->codec->extradata_size > 0) {
- extra = avstream->codec->extradata_size;
- extradata = avstream->codec->extradata;
+ if(avstream->codecpar->extradata_size > 0) {
+ extra = avstream->codecpar->extradata_size;
+ extradata = avstream->codecpar->extradata;
}
MPEG1VIDEOINFO *mp1vi = (MPEG1VIDEOINFO *)CoTaskMemAlloc(sizeof(MPEG1VIDEOINFO) + extra);
@@ -356,9 +359,9 @@ MPEG2VIDEOINFO *CLAVFVideoHelper::CreateMPEG2VI(const AVStream *avstream, ULONG
VIDEOINFOHEADER2 *vih2 = CreateVIH2(avstream, size, container);
if (!vih2) return nullptr;
- if(avstream->codec->extradata_size > 0) {
- extra = avstream->codec->extradata_size;
- extradata = avstream->codec->extradata;
+ if(avstream->codecpar->extradata_size > 0) {
+ extra = avstream->codecpar->extradata_size;
+ extradata = avstream->codecpar->extradata;
}
MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)CoTaskMemAlloc(sizeof(MPEG2VIDEOINFO) + max(extra - 4, 0));
@@ -368,23 +371,23 @@ MPEG2VIDEOINFO *CLAVFVideoHelper::CreateMPEG2VI(const AVStream *avstream, ULONG
mp2vi->hdr.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
// Set profile/level if we know them
- mp2vi->dwProfile = (avstream->codec->profile != FF_PROFILE_UNKNOWN) ? avstream->codec->profile : 0;
- mp2vi->dwLevel = (avstream->codec->level != FF_LEVEL_UNKNOWN) ? avstream->codec->level : 0;
+ mp2vi->dwProfile = (avstream->codecpar->profile != FF_PROFILE_UNKNOWN) ? avstream->codecpar->profile : 0;
+ mp2vi->dwLevel = (avstream->codecpar->level != FF_LEVEL_UNKNOWN) ? avstream->codecpar->level : 0;
//mp2vi->dwFlags = 4; // where do we get flags otherwise..?
if(extra > 0)
{
BOOL bCopyUntouched = FALSE;
- if(avstream->codec->codec_id == AV_CODEC_ID_H264)
+ if(avstream->codecpar->codec_id == AV_CODEC_ID_H264)
{
int ret = ProcessH264Extradata(extradata, extra, mp2vi, bConvertToAVC1);
if (ret < 0)
bCopyUntouched = TRUE;
- } else if (avstream->codec->codec_id == AV_CODEC_ID_HEVC) {
+ } else if (avstream->codecpar->codec_id == AV_CODEC_ID_HEVC) {
int ret = ProcessHEVCExtradata(extradata, extra, mp2vi);
if (ret < 0)
bCopyUntouched = TRUE;
- } else if (avstream->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+ } else if (avstream->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
CExtradataParser parser = CExtradataParser(extradata, extra);
mp2vi->cbSequenceHeader = (DWORD)parser.ParseMPEGSequenceHeader((BYTE *)&mp2vi->dwSequenceHeader[0]);
mp2vi->hdr.bmiHeader.biPlanes = 1;