summaryrefslogtreecommitdiff
path: root/src/codec/ffmpeg
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-01-29 16:45:30 -0500
committerAndrew Opalach <andrew@akon.city> 2025-01-29 16:45:30 -0500
commit6134465ddc10f8b43bddf74209f0ec8654595041 (patch)
tree49eb55da3d08abdc7dea9628c3ae9674dfe7afde /src/codec/ffmpeg
parent457a3cc1a04e45e31370d9083186436b0d12ab1d (diff)
downloadcamu-6134465ddc10f8b43bddf74209f0ec8654595041.tar.gz
camu-6134465ddc10f8b43bddf74209f0ec8654595041.tar.bz2
camu-6134465ddc10f8b43bddf74209f0ec8654595041.zip
Fixes and optimizations around seek and loop
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/codec/ffmpeg')
-rw-r--r--src/codec/ffmpeg/decoder.c5
-rw-r--r--src/codec/ffmpeg/demuxer.c1
2 files changed, 4 insertions, 2 deletions
diff --git a/src/codec/ffmpeg/decoder.c b/src/codec/ffmpeg/decoder.c
index 0462090..d3c9f41 100644
--- a/src/codec/ffmpeg/decoder.c
+++ b/src/codec/ffmpeg/decoder.c
@@ -9,6 +9,7 @@
#include "decoder.h"
#ifndef CAMU_SINK_NO_VIDEO
+#ifdef CAMU_FF_DECODER_HWACCEL
static s32 get_buffer2(AVCodecContext *context, AVFrame *pic, s32 flags)
{
struct camu_ff_decoder *av = (struct camu_ff_decoder *)context->opaque;
@@ -18,7 +19,6 @@ static s32 get_buffer2(AVCodecContext *context, AVFrame *pic, s32 flags)
return ret;
}
-#ifdef CAMU_FF_DECODER_HWACCEL
static s32 init_hwframe_context(struct camu_ff_decoder *av, AVCodecContext *context, AVBufferRef *hw_device_context)
{
AVBufferRef *hw_frames_ref;
@@ -245,9 +245,10 @@ static bool ff_decoder_init(struct camu_decoder *dec, struct camu_renderer *rend
#ifndef CAMU_SINK_NO_VIDEO
if (codecpar->codec_type == AVMEDIA_TYPE_VIDEO && renderer && renderer->get_buffer2) {
av->renderer = renderer;
+ // libplacebo's get_buffer2 take a really long time to discard frames on opengl + no hwaccel.
+#ifdef CAMU_FF_DECODER_HWACCEL
av->codec_context->opaque = av;
av->codec_context->get_buffer2 = get_buffer2;
-#ifdef CAMU_FF_DECODER_HWACCEL
if (av->hw_device_type != AV_HWDEVICE_TYPE_NONE) {
av->codec_context->get_format = get_hw_format;
}
diff --git a/src/codec/ffmpeg/demuxer.c b/src/codec/ffmpeg/demuxer.c
index b3e5873..5cb3ceb 100644
--- a/src/codec/ffmpeg/demuxer.c
+++ b/src/codec/ffmpeg/demuxer.c
@@ -162,6 +162,7 @@ static bool ff_demuxer_seek(struct camu_demuxer *demux, u64 pos)
al_assert(pos <= INT64_MAX);
if (pos > av->duration) pos = av->duration;
if (av->eof) {
+ // avio_flush() here probably does nothing.
avio_flush(av->io_context);
avformat_flush(av->format_context);
av->eof = false;