summaryrefslogtreecommitdiff
path: root/src/codec/ffmpeg
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-03-03 12:53:14 -0500
committerAndrew Opalach <andrew@akon.city> 2025-03-03 12:53:14 -0500
commit1224a43bbde9ef2297c7ee638b1928a07488cc3d (patch)
tree8cfb0ffe2f35c9c12bc20ab65185f08946eda243 /src/codec/ffmpeg
parent000ce1f671d1f05b76202fd128e272e4ac9da683 (diff)
downloadcamu-1224a43bbde9ef2297c7ee638b1928a07488cc3d.tar.gz
camu-1224a43bbde9ef2297c7ee638b1928a07488cc3d.tar.bz2
camu-1224a43bbde9ef2297c7ee638b1928a07488cc3d.zip
Fix vcr memory leak, subtitle upload/render sync
- Some sink behavior fixes. - Fix clock sync when seeking. - Add relative seek bind. Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/codec/ffmpeg')
-rw-r--r--src/codec/ffmpeg/decoder.c14
-rw-r--r--src/codec/ffmpeg/decoder.h2
-rw-r--r--src/codec/ffmpeg/meson.build28
-rw-r--r--src/codec/ffmpeg/resampler.c1
4 files changed, 24 insertions, 21 deletions
diff --git a/src/codec/ffmpeg/decoder.c b/src/codec/ffmpeg/decoder.c
index 47b5b01..5f4de67 100644
--- a/src/codec/ffmpeg/decoder.c
+++ b/src/codec/ffmpeg/decoder.c
@@ -90,7 +90,8 @@ static s32 init_hwdevice_context(struct camu_ff_decoder *av, AVCodecContext *con
}
context->hw_device_ctx = av_buffer_ref(av->hw_context);
- context->extra_hw_frames = 40;
+ // Note that context->extra_hw_frames has the ability to cause corruption.
+ context->extra_hw_frames = 18;
al_log_info("ff_decoder", "Using %s hardware decoding.", av_hwdevice_get_type_name(av->hw_device_type));
@@ -237,13 +238,14 @@ static bool ff_decoder_init(struct camu_decoder *dec, struct camu_renderer *rend
#ifdef CAMU_FF_DECODER_HWACCEL
if (attempt_hwdec && av->hw_device_type != AV_HWDEVICE_TYPE_NONE) {
//av->codec_context->codec_id = codec->id;
- if (init_hwdevice_context(av, av->codec_context) < 0) {
+ if (init_hwdevice_context(av, av->codec_context) == 0) {
+ av->renderer = renderer;
+ av->codec_context->opaque = av;
+ av->codec_context->get_buffer2 = get_buffer2;
+ av->codec_context->get_format = get_hw_format;
+ } else {
av->hw_device_type = AV_HWDEVICE_TYPE_NONE;
}
- av->renderer = renderer;
- av->codec_context->opaque = av;
- av->codec_context->get_buffer2 = get_buffer2;
- av->codec_context->get_format = get_hw_format;
}
#else
(void)renderer;
diff --git a/src/codec/ffmpeg/decoder.h b/src/codec/ffmpeg/decoder.h
index 4aa3d32..f698a6d 100644
--- a/src/codec/ffmpeg/decoder.h
+++ b/src/codec/ffmpeg/decoder.h
@@ -13,12 +13,14 @@ struct camu_ff_decoder {
struct camu_decoder dec;
AVCodecContext *codec_context;
struct camu_renderer *renderer;
+#ifdef CAMU_FF_DECODER_HWACCEL
array(const AVCodec *) supported_hw_codecs;
array(enum AVHWDeviceType) supported_hw_devices;
AVBufferRef *hw_context;
enum AVHWDeviceType hw_device_type;
enum AVPixelFormat hw_pix_fmt;
bool use_frames_context;
+#endif
void (*callback)(void *, struct camu_codec_frame *);
void *userdata;
};
diff --git a/src/codec/ffmpeg/meson.build b/src/codec/ffmpeg/meson.build
index cd6c7d3..dfbf624 100644
--- a/src/codec/ffmpeg/meson.build
+++ b/src/codec/ffmpeg/meson.build
@@ -27,16 +27,16 @@ ffmpeg_client_deps = []
libavutil = dependency('libavutil', required: false)
libavformat = dependency('libavformat', required: false)
libavcodec = dependency('libavcodec', required: false)
-libavdevice = dependency('libavdevice', required: false)
+#libavdevice = dependency('libavdevice', required: false)
libswresample = dependency('libswresample', required: false)
libswscale = dependency('libswscale', required: false)
-if not (libavutil.found() and libavformat.found() and libavcodec.found() and libavdevice.found() and libswresample.found() and libswscale.found())
+if not (libavutil.found() and libavformat.found() and libavcodec.found() and libswresample.found() and libswscale.found())
ffmpeg_proj = subproject('ffmpeg', required: false)
if ffmpeg_proj.found()
libavutil = ffmpeg_proj.get_variable('avutil')
libavformat = ffmpeg_proj.get_variable('avformat')
libavcodec = ffmpeg_proj.get_variable('avcodec')
- libavdevice = ffmpeg_proj.get_variable('avdevice')
+ #libavdevice = ffmpeg_proj.get_variable('avdevice')
libswresample = ffmpeg_proj.get_variable('swresample')
libswscale = ffmpeg_proj.get_variable('swscale')
# Only used to set include dirs for FFmpeg.
@@ -56,18 +56,16 @@ else
ffmpeg_version_string = run_command('sh', join_paths(meson.current_source_dir(), 'version.sh'), check: true).stdout().strip()
endif
-# This is probably meaningless compared to libav* versions, it's just something I wanted.
-ffmpeg_args += ['-DFFMPEG_VERSION="' + ffmpeg_version_string + '"']
-
-soxr = compiler.find_library('soxr', required: false)
-if soxr.found()
- ffmpeg_client_deps += [soxr]
- ffmpeg_args += ['-DCAMU_HAVE_SOXR']
-endif
-
-if libavutil.found() and libavformat.found() and libavcodec.found() and libavdevice.found() and libswresample.found() and libswscale.found()
- ffmpeg_server_deps += [libavutil, libavformat, libavcodec, libavdevice]
- ffmpeg_client_deps += [libavutil, libavformat, libavcodec, libavdevice, libswresample, libswscale]
+if libavutil.found() and libavformat.found() and libavcodec.found() and libswresample.found() and libswscale.found()
+ # This is probably meaningless compared to libav* versions, it's just something I wanted.
+ ffmpeg_args += ['-DFFMPEG_VERSION="' + ffmpeg_version_string + '"']
+ ffmpeg_server_deps += [libavutil, libavformat, libavcodec]
+ ffmpeg_client_deps += [libavutil, libavformat, libavcodec, libswresample, libswscale]
+ soxr = compiler.find_library('soxr', required: false)
+ if soxr.found()
+ ffmpeg_client_deps += [soxr]
+ ffmpeg_args += ['-DCAMU_HAVE_SOXR']
+ endif
codec_server_deps += [
declare_dependency(sources: ffmpeg_server_src,
dependencies: [ffmpeg_deps, ffmpeg_server_deps], compile_args: ffmpeg_args)
diff --git a/src/codec/ffmpeg/resampler.c b/src/codec/ffmpeg/resampler.c
index d2c8f62..61e8c9e 100644
--- a/src/codec/ffmpeg/resampler.c
+++ b/src/codec/ffmpeg/resampler.c
@@ -26,6 +26,7 @@ static bool ff_resampler_init(struct camu_resampler *resamp, struct camu_resampl
#ifdef CAMU_HAVE_SOXR
// Slower but more accurate resampler.
av_opt_set_int(av->resample_context, "resampler", SWR_ENGINE_SOXR, 0);
+ al_log_info("ff_resampler", "Using SoX resampler.");
#endif
if (swr_init(av->resample_context) != 0) {