diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-07-24 13:30:30 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-09-26 18:25:21 +0200 |
commit | 1ebd521a4e503c1e4697273a984e6de2c5f8886d (patch) | |
tree | 8068a29e811ac003b9e590920a722d2f86ea0921 /fftools | |
parent | 70f7bbeade57ab5c7fa14b2450d46fb3b87466d7 (diff) | |
download | ffmpeg-1ebd521a4e503c1e4697273a984e6de2c5f8886d.tar.gz |
fftools/ffmpeg_enc: stop using OutputStream in hw_device_setup_for_encode()
The only variable accessed from it is AVCodecContext, which we can
pass directly.
Also, this function currently logs into the AVCodecContext, which is
wrong. Log to Encoder instead.
Diffstat (limited to 'fftools')
-rw-r--r-- | fftools/ffmpeg_enc.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 2e1c7f27c1..c11ec218d7 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -110,34 +110,35 @@ int enc_alloc(Encoder **penc, const AVCodec *codec, return 0; } -static int hw_device_setup_for_encode(OutputStream *ost, AVBufferRef *frames_ref) +static int hw_device_setup_for_encode(Encoder *e, AVCodecContext *enc_ctx, + AVBufferRef *frames_ref) { const AVCodecHWConfig *config; HWDevice *dev = NULL; if (frames_ref && ((AVHWFramesContext*)frames_ref->data)->format == - ost->enc_ctx->pix_fmt) { + enc_ctx->pix_fmt) { // Matching format, will try to use hw_frames_ctx. } else { frames_ref = NULL; } for (int i = 0;; i++) { - config = avcodec_get_hw_config(ost->enc_ctx->codec, i); + config = avcodec_get_hw_config(enc_ctx->codec, i); if (!config) break; if (frames_ref && config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX && (config->pix_fmt == AV_PIX_FMT_NONE || - config->pix_fmt == ost->enc_ctx->pix_fmt)) { - av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using input " + config->pix_fmt == enc_ctx->pix_fmt)) { + av_log(e, AV_LOG_VERBOSE, "Using input " "frames context (format %s) with %s encoder.\n", - av_get_pix_fmt_name(ost->enc_ctx->pix_fmt), - ost->enc_ctx->codec->name); - ost->enc_ctx->hw_frames_ctx = av_buffer_ref(frames_ref); - if (!ost->enc_ctx->hw_frames_ctx) + av_get_pix_fmt_name(enc_ctx->pix_fmt), + enc_ctx->codec->name); + enc_ctx->hw_frames_ctx = av_buffer_ref(frames_ref); + if (!enc_ctx->hw_frames_ctx) return AVERROR(ENOMEM); return 0; } @@ -148,11 +149,11 @@ static int hw_device_setup_for_encode(OutputStream *ost, AVBufferRef *frames_ref } if (dev) { - av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using device %s " + av_log(e, AV_LOG_VERBOSE, "Using device %s " "(type %s) with %s encoder.\n", dev->name, - av_hwdevice_get_type_name(dev->type), ost->enc_ctx->codec->name); - ost->enc_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref); - if (!ost->enc_ctx->hw_device_ctx) + av_hwdevice_get_type_name(dev->type), enc_ctx->codec->name); + enc_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref); + if (!enc_ctx->hw_device_ctx) return AVERROR(ENOMEM); } else { // No device required, or no device available. @@ -335,7 +336,7 @@ int enc_open(void *opaque, const AVFrame *frame) enc_ctx->flags |= AV_CODEC_FLAG_FRAME_DURATION; - ret = hw_device_setup_for_encode(ost, frame ? frame->hw_frames_ctx : NULL); + ret = hw_device_setup_for_encode(e, enc_ctx, frame ? frame->hw_frames_ctx : NULL); if (ret < 0) { av_log(e, AV_LOG_ERROR, "Encoding hardware device setup failed: %s\n", av_err2str(ret)); |