summaryrefslogtreecommitdiffstats
path: root/video/decode/vd_lavc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-10-31 15:29:13 +0100
committerwm4 <wm4@nowhere>2017-10-31 15:29:13 +0100
commitf27a9aaa17eaced765718d096d0b3284c3f15b1f (patch)
tree2927b817bfe16d95274772be1435b29611f0412f /video/decode/vd_lavc.c
parent7fd1359fcf72f28eb7bc24392f50f1fdbd75b956 (diff)
downloadmpv-f27a9aaa17eaced765718d096d0b3284c3f15b1f.tar.bz2
mpv-f27a9aaa17eaced765718d096d0b3284c3f15b1f.tar.xz
vd_lavc: remove more dead legacy code
All of this was dead code and completely unused. get_buffer2_hwdec() is the biggest chunk. One unfortunate thing about it is that, while it was active, it could perform a software fallback much faster, because it didn't have to wait until a full frame is decoded (it actually decoded a full frame, but the current code has to decode many more frames due to the codec delay, because the current code waits until the API returns a decoded frame.) We should probably restore the latter, although since it's an optional optimization, and the current behavior doesn't change with the removal of this code, don't actually do anything about it.
Diffstat (limited to 'video/decode/vd_lavc.c')
-rw-r--r--video/decode/vd_lavc.c71
1 files changed, 2 insertions, 69 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 3b22159f2b..75cf8a6416 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -61,7 +61,6 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
static void uninit_avctx(struct dec_video *vd);
static int get_buffer2_direct(AVCodecContext *avctx, AVFrame *pic, int flags);
-static int get_buffer2_hwdec(AVCodecContext *avctx, AVFrame *pic, int flags);
static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx,
const enum AVPixelFormat *pix_fmt);
@@ -191,13 +190,6 @@ static const struct vd_lavc_hwdec mp_vd_lavc_vaapi = {
.image_format = IMGFMT_VAAPI,
.generic_hwaccel = true,
.set_hwframes = true,
- .static_pool = true,
- .pixfmt_map = (const enum AVPixelFormat[][2]) {
- {AV_PIX_FMT_YUV420P10, AV_PIX_FMT_P010},
- {AV_PIX_FMT_YUV420P, AV_PIX_FMT_NV12},
- {AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NV12},
- {AV_PIX_FMT_NONE}
- },
};
#include "video/vaapi.h"
@@ -208,14 +200,7 @@ static const struct vd_lavc_hwdec mp_vd_lavc_vaapi_copy = {
.image_format = IMGFMT_VAAPI,
.generic_hwaccel = true,
.set_hwframes = true,
- .static_pool = true,
.create_dev = va_create_standalone,
- .pixfmt_map = (const enum AVPixelFormat[][2]) {
- {AV_PIX_FMT_YUV420P10, AV_PIX_FMT_P010},
- {AV_PIX_FMT_YUV420P, AV_PIX_FMT_NV12},
- {AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NV12},
- {AV_PIX_FMT_NONE}
- },
};
#endif
@@ -225,11 +210,6 @@ static const struct vd_lavc_hwdec mp_vd_lavc_vdpau = {
.image_format = IMGFMT_VDPAU,
.generic_hwaccel = true,
.set_hwframes = true,
- .pixfmt_map = (const enum AVPixelFormat[][2]) {
- {AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P},
- {AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUV420P},
- {AV_PIX_FMT_NONE}
- },
};
#include "video/vdpau.h"
@@ -241,11 +221,6 @@ static const struct vd_lavc_hwdec mp_vd_lavc_vdpau_copy = {
.generic_hwaccel = true,
.set_hwframes = true,
.create_dev = vdpau_create_standalone,
- .pixfmt_map = (const enum AVPixelFormat[][2]) {
- {AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P},
- {AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUV420P},
- {AV_PIX_FMT_NONE}
- },
};
#endif
@@ -408,7 +383,7 @@ static int hwdec_probe(struct dec_video *vd, struct vd_lavc_hwdec *hwdec,
r = hwdec->probe(ctx, hwdec, codec);
if (hwdec->generic_hwaccel) {
assert(!hwdec->probe && !hwdec->init && !hwdec->init_decoder &&
- !hwdec->uninit && !hwdec->allocate_image);
+ !hwdec->uninit);
struct mp_hwdec_ctx *dev = hwdec_create_dev(vd, hwdec, autoprobe);
if (!dev)
return hwdec->copying ? -1 : HWDEC_ERR_NO_CTX;
@@ -615,8 +590,6 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
avctx->hwaccel_flags |= AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH;
if (ctx->hwdec->image_format)
avctx->get_format = get_format_hwdec;
- if (ctx->hwdec->allocate_image)
- avctx->get_buffer2 = get_buffer2_hwdec;
if (ctx->hwdec->init && ctx->hwdec->init(ctx) < 0)
goto error;
if (ctx->hwdec->generic_hwaccel) {
@@ -855,8 +828,7 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx,
ctx->hwdec_h != avctx->coded_height ||
ctx->hwdec_fmt != ctx->hwdec->image_format ||
ctx->hwdec_profile != avctx->profile ||
- ctx->hwdec_request_reinit ||
- ctx->hwdec->volatile_context;
+ ctx->hwdec_request_reinit;
ctx->hwdec_w = avctx->coded_width;
ctx->hwdec_h = avctx->coded_height;
ctx->hwdec_fmt = ctx->hwdec->image_format;
@@ -971,45 +943,6 @@ fallback:
return avcodec_default_get_buffer2(avctx, pic, flags);
}
-static int get_buffer2_hwdec(AVCodecContext *avctx, AVFrame *pic, int flags)
-{
- struct dec_video *vd = avctx->opaque;
- vd_ffmpeg_ctx *ctx = vd->priv;
-
- int imgfmt = pixfmt2imgfmt(pic->format);
- if (!ctx->hwdec || ctx->hwdec_fmt != imgfmt)
- ctx->hwdec_failed = true;
-
- /* Hardware decoding failed, and we will trigger a proper fallback later
- * when returning from the decode call. (We are forcing complete
- * reinitialization later to reset the thread count properly.)
- */
- if (ctx->hwdec_failed)
- return avcodec_default_get_buffer2(avctx, pic, flags);
-
- // We expect it to use the exact size used to create the hw decoder in
- // get_format_hwdec(). For cropped video, this is expected to be the
- // uncropped size (usually coded_width/coded_height).
- int w = pic->width;
- int h = pic->height;
-
- if (imgfmt != ctx->hwdec_fmt && w != ctx->hwdec_w && h != ctx->hwdec_h)
- return AVERROR(EINVAL);
-
- struct mp_image *mpi = ctx->hwdec->allocate_image(ctx, w, h);
- if (!mpi)
- return AVERROR(ENOMEM);
-
- for (int i = 0; i < 4; i++) {
- pic->data[i] = mpi->planes[i];
- pic->buf[i] = mpi->bufs[i];
- mpi->bufs[i] = NULL;
- }
- talloc_free(mpi);
-
- return 0;
-}
-
static bool prepare_decoding(struct dec_video *vd)
{
vd_ffmpeg_ctx *ctx = vd->priv;