|
|
12e554d |
diff --git a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp
|
|
|
12e554d |
--- a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp
|
|
|
12e554d |
+++ b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp
|
|
|
12e554d |
@@ -206,15 +206,49 @@
|
|
|
12e554d |
media::TimeUnit pts = aSample->mTime;
|
|
|
12e554d |
|
|
|
12e554d |
while (packet.size > 0) {
|
|
|
12e554d |
- int decoded;
|
|
|
12e554d |
- int bytesConsumed =
|
|
|
12e554d |
+ int decoded = false;
|
|
|
12e554d |
+ int bytesConsumed = -1;
|
|
|
12e554d |
+#if LIBAVCODEC_VERSION_MAJOR < 59
|
|
|
12e554d |
+ bytesConsumed =
|
|
|
12e554d |
mLib->avcodec_decode_audio4(mCodecContext, mFrame, &decoded, &packet);
|
|
|
12e554d |
-
|
|
|
12e554d |
if (bytesConsumed < 0) {
|
|
|
12e554d |
NS_WARNING("FFmpeg audio decoder error.");
|
|
|
12e554d |
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
|
|
12e554d |
RESULT_DETAIL("FFmpeg audio error:%d", bytesConsumed));
|
|
|
12e554d |
}
|
|
|
12e554d |
+#else
|
|
|
12e554d |
+# define AVERROR_OK 0
|
|
|
12e554d |
+
|
|
|
12e554d |
+ int ret = mLib->avcodec_receive_frame(mCodecContext, mFrame);
|
|
|
12e554d |
+ switch (ret) {
|
|
|
12e554d |
+ case AVERROR_OK:
|
|
|
12e554d |
+ decoded = true;
|
|
|
12e554d |
+ break;
|
|
|
12e554d |
+ case AVERROR(EAGAIN):
|
|
|
12e554d |
+ break;
|
|
|
12e554d |
+ case int(AVERROR_EOF): {
|
|
|
12e554d |
+ FFMPEG_LOG(" End of stream.");
|
|
|
12e554d |
+ return MediaResult(NS_ERROR_DOM_MEDIA_END_OF_STREAM,
|
|
|
12e554d |
+ RESULT_DETAIL("End of stream"));
|
|
|
12e554d |
+ }
|
|
|
12e554d |
+ }
|
|
|
12e554d |
+ ret = mLib->avcodec_send_packet(mCodecContext, &packet);
|
|
|
12e554d |
+ switch (ret) {
|
|
|
12e554d |
+ case AVERROR_OK:
|
|
|
12e554d |
+ bytesConsumed = packet.size;
|
|
|
12e554d |
+ break;
|
|
|
12e554d |
+ case AVERROR(EAGAIN):
|
|
|
12e554d |
+ break;
|
|
|
12e554d |
+ case int(AVERROR_EOF):
|
|
|
12e554d |
+ FFMPEG_LOG(" End of stream.");
|
|
|
12e554d |
+ return MediaResult(NS_ERROR_DOM_MEDIA_END_OF_STREAM,
|
|
|
12e554d |
+ RESULT_DETAIL("End of stream"));
|
|
|
12e554d |
+ default:
|
|
|
12e554d |
+ NS_WARNING("FFmpeg audio decoder error.");
|
|
|
12e554d |
+ return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
|
|
12e554d |
+ RESULT_DETAIL("FFmpeg audio error"));
|
|
|
12e554d |
+ }
|
|
|
12e554d |
+#endif
|
|
|
12e554d |
|
|
|
12e554d |
if (decoded) {
|
|
|
12e554d |
if (mFrame->format != AV_SAMPLE_FMT_FLT &&
|
|
|
12e554d |
diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
|
|
|
12e554d |
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
|
|
|
12e554d |
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
|
|
|
12e554d |
@@ -39,6 +39,9 @@
|
|
|
12e554d |
# define AV_PIX_FMT_YUV444P10LE PIX_FMT_YUV444P10LE
|
|
|
12e554d |
# define AV_PIX_FMT_NONE PIX_FMT_NONE
|
|
|
12e554d |
#endif
|
|
|
12e554d |
+#if LIBAVCODEC_VERSION_MAJOR > 58
|
|
|
12e554d |
+# define AV_PIX_FMT_VAAPI_VLD AV_PIX_FMT_VAAPI
|
|
|
12e554d |
+#endif
|
|
|
12e554d |
#include "mozilla/PodOperations.h"
|
|
|
12e554d |
#include "mozilla/StaticPrefs_media.h"
|
|
|
12e554d |
#include "mozilla/TaskQueue.h"
|
|
|
12e554d |
@@ -766,6 +769,14 @@
|
|
|
12e554d |
}
|
|
|
12e554d |
#endif
|
|
|
12e554d |
|
|
|
12e554d |
+static int64_t GetFramePts(AVFrame* aFrame) {
|
|
|
12e554d |
+#if LIBAVCODEC_VERSION_MAJOR > 58
|
|
|
12e554d |
+ return aFrame->pts;
|
|
|
12e554d |
+#else
|
|
|
12e554d |
+ return aFrame->pkt_pts;
|
|
|
12e554d |
+#endif
|
|
|
12e554d |
+}
|
|
|
12e554d |
+
|
|
|
12e554d |
MediaResult FFmpegVideoDecoder<LIBAV_VER>::DoDecode(
|
|
|
12e554d |
MediaRawData* aSample, uint8_t* aData, int aSize, bool* aGotFrame,
|
|
|
12e554d |
MediaDataDecoder::DecodedData& aResults) {
|
|
|
12e554d |
@@ -831,7 +842,7 @@
|
|
|
12e554d |
MediaResult rv;
|
|
|
12e554d |
# ifdef MOZ_WAYLAND_USE_VAAPI
|
|
|
12e554d |
if (IsHardwareAccelerated()) {
|
|
|
12e554d |
- rv = CreateImageVAAPI(mFrame->pkt_pos, mFrame->pkt_pts,
|
|
|
12e554d |
+ rv = CreateImageVAAPI(mFrame->pkt_pos, GetFramePts(mFrame),
|
|
|
12e554d |
mFrame->pkt_duration, aResults);
|
|
|
12e554d |
// If VA-API playback failed, just quit. Decoder is going to be restarted
|
|
|
12e554d |
// without VA-API.
|
|
|
12e554d |
@@ -844,8 +855,8 @@
|
|
|
12e554d |
} else
|
|
|
12e554d |
# endif
|
|
|
12e554d |
{
|
|
|
12e554d |
- rv = CreateImage(mFrame->pkt_pos, mFrame->pkt_pts, mFrame->pkt_duration,
|
|
|
12e554d |
- aResults);
|
|
|
12e554d |
+ rv = CreateImage(mFrame->pkt_pos, GetFramePts(mFrame),
|
|
|
12e554d |
+ mFrame->pkt_duration, aResults);
|
|
|
12e554d |
}
|
|
|
12e554d |
if (NS_FAILED(rv)) {
|
|
|
12e554d |
return rv;
|
|
|
12e554d |
@@ -879,9 +890,9 @@
|
|
|
12e554d |
"DoDecodeFrame:decode_video: rv=%d decoded=%d "
|
|
|
12e554d |
"(Input: pts(%" PRId64 ") dts(%" PRId64 ") Output: pts(%" PRId64
|
|
|
12e554d |
") "
|
|
|
12e554d |
- "opaque(%" PRId64 ") pkt_pts(%" PRId64 ") pkt_dts(%" PRId64 "))",
|
|
|
12e554d |
+ "opaque(%" PRId64 ") pts(%" PRId64 ") pkt_dts(%" PRId64 "))",
|
|
|
12e554d |
bytesConsumed, decoded, packet.pts, packet.dts, mFrame->pts,
|
|
|
12e554d |
- mFrame->reordered_opaque, mFrame->pkt_pts, mFrame->pkt_dts);
|
|
|
12e554d |
+ mFrame->reordered_opaque, mFrame->pts, mFrame->pkt_dts);
|
|
|
12e554d |
|
|
|
12e554d |
if (bytesConsumed < 0) {
|
|
|
12e554d |
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
|
|
12e554d |
@@ -896,7 +907,8 @@
|
|
|
12e554d |
}
|
|
|
12e554d |
|
|
|
12e554d |
// If we've decoded a frame then we need to output it
|
|
|
12e554d |
- int64_t pts = mPtsContext.GuessCorrectPts(mFrame->pkt_pts, mFrame->pkt_dts);
|
|
|
12e554d |
+ int64_t pts =
|
|
|
12e554d |
+ mPtsContext.GuessCorrectPts(GetFramePts(mFrame), mFrame->pkt_dts);
|
|
|
12e554d |
// Retrieve duration from dts.
|
|
|
12e554d |
// We use the first entry found matching this dts (this is done to
|
|
|
12e554d |
// handle damaged file with multiple frames with the same dts)
|
|
|
12e554d |
|