summaryrefslogtreecommitdiff
path: root/src/codec/ffmpeg
diff options
context:
space:
mode:
Diffstat (limited to 'src/codec/ffmpeg')
-rw-r--r--src/codec/ffmpeg/decoder.c31
-rw-r--r--src/codec/ffmpeg/decoder.h4
-rw-r--r--src/codec/ffmpeg/demuxer.c2
3 files changed, 20 insertions, 17 deletions
diff --git a/src/codec/ffmpeg/decoder.c b/src/codec/ffmpeg/decoder.c
index dfabe05..a6431b1 100644
--- a/src/codec/ffmpeg/decoder.c
+++ b/src/codec/ffmpeg/decoder.c
@@ -1,5 +1,6 @@
-#include <al/lib.h>
+#define AL_LOG_SECTION "ff_decoder"
#include <al/log.h>
+#include <al/lib.h>
#include <libavutil/cpu.h>
#ifndef CAMU_SINK_NO_VIDEO
@@ -30,7 +31,7 @@ static s32 init_hwframe_context(struct camu_ff_decoder *av, AVCodecContext *cont
{
AVBufferRef *hw_frames_ref;
if (!(hw_frames_ref = av_hwframe_ctx_alloc(hw_device_context))) {
- al_log_error("ff_decoder", "Failed to create hardware frame context.");
+ error("Failed to create hardware frame context.");
return -1;
}
@@ -44,7 +45,7 @@ static s32 init_hwframe_context(struct camu_ff_decoder *av, AVCodecContext *cont
s32 ret = av_hwframe_ctx_init(hw_frames_ref);
if (ret < 0) {
- al_log_error("ff_decoder", "Failed to initialize hardware frame context (%s).", av_err2str(ret));
+ error("Failed to initialize hardware frame context (%s).", av_err2str(ret));
av_buffer_unref(&hw_frames_ref);
return ret;
}
@@ -70,7 +71,7 @@ static enum AVPixelFormat get_hw_format(AVCodecContext *context, const enum AVPi
}
}
- al_log_error("ff_decoder", "Failed to get HW surface format.");
+ error("Failed to get HW surface format.");
return avcodec_default_get_format(context, pix_fmts);
}
@@ -81,7 +82,7 @@ static s32 init_hwdevice_context(struct camu_ff_decoder *av, AVCodecContext *con
s32 ret = av_hwdevice_ctx_create(&av->hw_context, av->hw_device_type, NULL, NULL, 0);
if (ret < 0) {
- al_log_error("ff_decoder", "Failed to create specified HW device.");
+ error("Failed to create specified HW device.");
return ret;
}
@@ -89,7 +90,7 @@ static s32 init_hwdevice_context(struct camu_ff_decoder *av, AVCodecContext *con
// 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));
+ info("Using %s hardware decoding.", av_hwdevice_get_type_name(av->hw_device_type));
return ret;
}
@@ -181,7 +182,7 @@ static bool ff_decoder_init(struct camu_decoder *dec, struct camu_renderer *rend
AVCodecParameters *codecpar = stream->av.stream->codecpar;
const AVCodec *codec = avcodec_find_decoder(codecpar->codec_id);
if (!codec) {
- al_log_error("ff_decoder", "Failed to find decoder.");
+ error("Failed to find decoder.");
goto err;
}
@@ -215,19 +216,19 @@ static bool ff_decoder_init(struct camu_decoder *dec, struct camu_renderer *rend
}
if (av->hw_device_type == AV_HWDEVICE_TYPE_NONE) {
- al_log_warn("ff_decoder", "Hardware accelerated video decoding of %s not supported.", codec->name);
+ warn("Hardware accelerated video decoding of %s not supported.", codec->name);
}
}
#endif
av->codec_context = avcodec_alloc_context3(codec);
if (!av->codec_context) {
- al_log_error("ff_decoder", "Failed to alloc codec context.");
+ error("Failed to alloc codec context.");
goto err;
}
if (avcodec_parameters_to_context(av->codec_context, codecpar) < 0) {
- al_log_error("ff_decoder", "Failed to copy codec parameters.");
+ error("Failed to copy codec parameters.");
goto err;
}
@@ -261,20 +262,20 @@ static bool ff_decoder_init(struct camu_decoder *dec, struct camu_renderer *rend
av->codec_context->thread_count = cpus;
// FF_THREAD_FRAME or FF_THREAD_SLICE.
av->codec_context->thread_type = FF_THREAD_FRAME;
- al_log_info("ff_decoder", "Using %i threads for decoder.", cpus);
+ info("Using %i threads for decoder.", cpus);
}
}
AVDictionary *opts = NULL;
s32 ret = avcodec_open2(av->codec_context, codec, &opts);
if (ret < 0) {
- al_log_error("ff_decoder", "Failed to open codec %s (%s).", codec->name, av_err2str(ret));
+ error("Failed to open codec %s (%s).", codec->name, av_err2str(ret));
goto err;
}
const char *long_name = codec->long_name ? codec->long_name : codec->name;
- s64 kbps = codecpar->bit_rate > 0 ? codecpar->bit_rate / 1000 : 0;
- al_log_info("ff_decoder", "Codec: %s (%s) %lldkbps.", codec->name, long_name, kbps);
+ s64 kbps = (codecpar->bit_rate > 0) ? codecpar->bit_rate / 1000 : 0;
+ info("Codec: %s (%s) %lldkbps.", codec->name, long_name, kbps);
av->callback = callback;
av->userdata = userdata;
@@ -289,7 +290,7 @@ static s32 send_packet(struct camu_ff_decoder *av, AVPacket *pkt)
{
s32 ret = avcodec_send_packet(av->codec_context, pkt);
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
- al_log_error("ff_decoder", "Error sending packet to the decoder (%s).", av_err2str(ret));
+ error("Error sending packet to the decoder (%s).", av_err2str(ret));
}
return ret;
}
diff --git a/src/codec/ffmpeg/decoder.h b/src/codec/ffmpeg/decoder.h
index aa9eb57..db7a6f8 100644
--- a/src/codec/ffmpeg/decoder.h
+++ b/src/codec/ffmpeg/decoder.h
@@ -5,7 +5,9 @@
#include "../codec.h"
-//#define CAMU_FF_DECODER_HWACCEL
+#ifndef CAMU_SINK_NO_VIDEO
+#define CAMU_FF_DECODER_HWACCEL
+#endif
struct camu_ff_decoder {
struct camu_decoder dec;
diff --git a/src/codec/ffmpeg/demuxer.c b/src/codec/ffmpeg/demuxer.c
index 9764f58..058a423 100644
--- a/src/codec/ffmpeg/demuxer.c
+++ b/src/codec/ffmpeg/demuxer.c
@@ -76,7 +76,7 @@ static bool ff_demuxer_init(struct camu_demuxer *demux, struct cch_handle *handl
#define GUESS_STREAM_IS_IMAGE(stream) \
(stream->duration >= 0 && stream->nb_frames <= 1 && (stream->avg_frame_rate.den == 0 && stream->r_frame_rate.den > 0))
- s64 default_duration = av->format_context->duration < 0 ? 0 : av->format_context->duration;
+ s64 default_duration = (av->format_context->duration < 0) ? 0 : av->format_context->duration;
av->duration = 0;
for (u32 i = 0; i < av->format_context->nb_streams; i++) {