hrev52168 adds 2 changesets to branch 'master'
old head: fc35866e55aebe23982d924f71d4444137a3703c
new head: b5d0ce85f454ed6f0dd64f6eb77302ac26dc5c4c
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=b5d0ce85f454+%5Efc35866e55ae
----------------------------------------------------------------------------
9467826d3121: AVFormatWriter: Remove OPEN_CODEC_CONTEXT hack
b5d0ce85f454: AVCodecEncoder/AVFormatReader: Remove kNoPTSValue hack
[ Barrett17 <b.vitruvio@xxxxxxxxx> ]
----------------------------------------------------------------------------
3 files changed, 10 insertions(+), 49 deletions(-)
.../media/plugins/ffmpeg/AVCodecEncoder.cpp | 5 ----
.../media/plugins/ffmpeg/AVFormatReader.cpp | 23 +++++++--------
.../media/plugins/ffmpeg/AVFormatWriter.cpp | 31 --------------------
############################################################################
Commit: 9467826d3121b639c710199b11ffa56e702aab13
URL: https://git.haiku-os.org/haiku/commit/?id=9467826d3121
Author: Barrett17 <b.vitruvio@xxxxxxxxx>
Date: Sun Aug 5 08:17:48 2018 UTC
AVFormatWriter: Remove OPEN_CODEC_CONTEXT hack
----------------------------------------------------------------------------
diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp
b/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp
index 47b1305d1e..8e2d9a9e22 100644
--- a/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp
+++ b/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp
@@ -48,10 +48,6 @@ static const size_t kIOBufferSize = 64 * 1024;
// TODO: This could depend on the BMediaFile creation flags, IIRC,
// they allow to specify a buffering mode.
-// NOTE: The following works around some weird bug in libavformat. We
-// have to open the AVFormatContext->AVStream->AVCodecContext, even though
-// we are not interested in donig any encoding here!!
-#define OPEN_CODEC_CONTEXT 1
#define GET_CONTEXT_DEFAULTS 0
typedef AVCodecID CodecID;
@@ -376,15 +372,6 @@ AVFormatWriter::~AVFormatWriter()
// Free the streams and close the AVCodecContexts
for(unsigned i = 0; i < fFormatContext->nb_streams; i++) {
-#if OPEN_CODEC_CONTEXT
- // We only need to close the AVCodecContext when we opened it.
- // This is experimental, see CommitHeader().
-
- // NOTE: Since the introduction of AVCodecParameters
- // I am not sure this logic is correct.
- if (fCodecOpened)
- avcodec_close(fFormatContext->streams[i]->codec);
-#endif
av_freep(&fFormatContext->streams[i]->codecpar);
av_freep(&fFormatContext->streams[i]);
}
@@ -455,24 +442,6 @@ AVFormatWriter::CommitHeader()
if (fCodecOpened)
return B_NOT_ALLOWED;
-#if OPEN_CODEC_CONTEXT
- for (unsigned i = 0; i < fFormatContext->nb_streams; i++) {
- AVStream* stream = fFormatContext->streams[i];
- // NOTE: Experimental, this should not be needed. Especially,
since
- // we have no idea (in the future) what CodecID some encoder
uses,
- // it may be an encoder from a different plugin.
- AVCodecContext* codecContext = stream->codec;
- codecContext->strict_std_compliance = -2;
- AVCodec* codec = avcodec_find_encoder(codecContext->codec_id);
- if (codec == NULL || avcodec_open2(codecContext, codec, NULL) <
0) {
- TRACE(" stream[%u] - failed to open AVCodecContext\n",
i);
- }
- TRACE(" stream[%u] time_base: (%d/%d), codec->time_base:
(%d/%d)\n",
- i, stream->time_base.num, stream->time_base.den,
- stream->codec->time_base.num,
stream->codec->time_base.den);
- }
-#endif
-
// We need to close the codecs we opened, even in case of failure.
fCodecOpened = true;
############################################################################
Revision: hrev52168
Commit: b5d0ce85f454ed6f0dd64f6eb77302ac26dc5c4c
URL: https://git.haiku-os.org/haiku/commit/?id=b5d0ce85f454
Author: Barrett17 <b.vitruvio@xxxxxxxxx>
Date: Sun Aug 5 08:19:35 2018 UTC
AVCodecEncoder/AVFormatReader: Remove kNoPTSValue hack
----------------------------------------------------------------------------
diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
index 31409412aa..c55006193d 100644
--- a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
+++ b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp
@@ -533,11 +533,6 @@ AVCodecEncoder::_CloseCodecIfNeeded()
}
-static const int64 kNoPTSValue = 0x8000000000000000LL;
- // NOTE: For some reasons, I have trouble with the avcodec.h define:
- // #define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
- // INT64_C is not defined here.
-
status_t
AVCodecEncoder::_EncodeAudio(const void* _buffer, int64 frameCount,
media_encode_info* info)
diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
index 57cdd67b00..5dfa7bd75c 100644
--- a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
+++ b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
@@ -49,9 +49,6 @@ extern "C" {
#define ERROR(a...) fprintf(stderr, a)
-static const int64 kNoPTSValue = AV_NOPTS_VALUE;
-
-
static uint32
avformat_to_beos_byte_order(AVSampleFormat format)
{
@@ -432,9 +429,9 @@ StreamBase::Duration() const
// for a couple of streams and are in line with the documentation, but
// unfortunately, libavformat itself seems to set the time_base and
// duration wrongly sometimes. :-(
- if ((int64)fStream->duration != kNoPTSValue)
+ if ((int64)fStream->duration != AV_NOPTS_VALUE)
return _ConvertFromStreamTimeBase(fStream->duration);
- else if ((int64)fContext->duration != kNoPTSValue)
+ else if ((int64)fContext->duration != AV_NOPTS_VALUE)
return (bigtime_t)fContext->duration;
return 0;
@@ -508,7 +505,7 @@ StreamBase::Seek(uint32 flags, int64* frame, bigtime_t*
time)
// know where we really seeked.
fReusePacket = false;
if (_NextPacket(true) == B_OK) {
- while (fPacket.pts == kNoPTSValue) {
+ while (fPacket.pts == AV_NOPTS_VALUE) {
fReusePacket = false;
if (_NextPacket(true) != B_OK)
return B_ERROR;
@@ -642,7 +639,7 @@ StreamBase::Seek(uint32 flags, int64* frame, bigtime_t*
time)
fReusePacket = false;
if (_NextPacket(true) == B_OK) {
- if (fPacket.pts != kNoPTSValue)
+ if (fPacket.pts != AV_NOPTS_VALUE)
foundTime =
_ConvertFromStreamTimeBase(fPacket.pts);
else
TRACE_SEEK(" no PTS in packet after
seeking\n");
@@ -704,9 +701,9 @@ StreamBase::GetNextChunk(const void** chunkBuffer,
// series (even for videos that contain B-frames).
// \see
http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/avformat.h;h=1e8a6294890d580cd9ebc684eaf4ce57c8413bd8;hb=9153b33a742c4e2a85ff6230aea0e75f5a8b26c2#l1623
bigtime_t presentationTimeStamp;
- if (fPacket.dts != kNoPTSValue)
+ if (fPacket.dts != AV_NOPTS_VALUE)
presentationTimeStamp = fPacket.dts;
- else if (fPacket.pts != kNoPTSValue)
+ else if (fPacket.pts != AV_NOPTS_VALUE)
presentationTimeStamp = fPacket.pts;
else
presentationTimeStamp = lastStreamDTS;
@@ -740,7 +737,7 @@ StreamBase::GetNextChunk(const void** chunkBuffer,
// static bigtime_t lastPrintTime = system_time();
// static BLocker printLock;
// if (fStream->index < 2) {
-// if (fPacket.pts != kNoPTSValue)
+// if (fPacket.pts != AV_NOPTS_VALUE)
// pts[fStream->index] =
_ConvertFromStreamTimeBase(fPacket.pts);
// printLock.Lock();
// bigtime_t now = system_time();
@@ -872,7 +869,7 @@ StreamBase::_ConvertToStreamTimeBase(bigtime_t time) const
{
int64 timeStamp = int64_t((double)time * fStream->time_base.den
/ (1000000.0 * fStream->time_base.num) + 0.5);
- if (fStream->start_time != kNoPTSValue)
+ if (fStream->start_time != AV_NOPTS_VALUE)
timeStamp += fStream->start_time;
return timeStamp;
}
@@ -881,7 +878,7 @@ StreamBase::_ConvertToStreamTimeBase(bigtime_t time) const
bigtime_t
StreamBase::_ConvertFromStreamTimeBase(int64_t time) const
{
- if (fStream->start_time != kNoPTSValue)
+ if (fStream->start_time != AV_NOPTS_VALUE)
time -= fStream->start_time;
return bigtime_t(1000000.0 * time * fStream->time_base.num
@@ -1207,7 +1204,7 @@ AVFormatReader::Stream::GetStreamInfo(int64* frameCount,
TRACE(" frameRate: %.4f\n", frameRate);
#ifdef TRACE_AVFORMAT_READER
- if (fStream->start_time != kNoPTSValue) {
+ if (fStream->start_time != AV_NOPTS_VALUE) {
bigtime_t startTime =
_ConvertFromStreamTimeBase(fStream->start_time);
TRACE(" start_time: %lld or %.5fs\n", startTime,
startTime / 1000000.0);