aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/decode
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2017-10-31 15:29:13 +0100
committerGravatar wm4 <wm4@nowhere>2017-10-31 15:29:13 +0100
commitf27a9aaa17eaced765718d096d0b3284c3f15b1f (patch)
tree2927b817bfe16d95274772be1435b29611f0412f /video/decode
parent7fd1359fcf72f28eb7bc24392f50f1fdbd75b956 (diff)
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')
-rw-r--r--video/decode/hw_d3d11va.c14
-rw-r--r--video/decode/hw_dxva2.c14
-rw-r--r--video/decode/lavc.h11
-rw-r--r--video/decode/vd_lavc.c71
4 files changed, 2 insertions, 108 deletions
diff --git a/video/decode/hw_d3d11va.c b/video/decode/hw_d3d11va.c
index 108f4f5720..95bfad38fe 100644
--- a/video/decode/hw_d3d11va.c
+++ b/video/decode/hw_d3d11va.c
@@ -92,15 +92,8 @@ const struct vd_lavc_hwdec mp_vd_lavc_d3d11va = {
.image_format = IMGFMT_D3D11VA,
.generic_hwaccel = true,
.set_hwframes = true,
- .static_pool = true,
.hwframes_refine = d3d_hwframes_refine,
.process_image = d3d11_update_image_attribs,
- .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}
- },
};
const struct vd_lavc_hwdec mp_vd_lavc_d3d11va_copy = {
@@ -110,13 +103,6 @@ const struct vd_lavc_hwdec mp_vd_lavc_d3d11va_copy = {
.generic_hwaccel = true,
.create_dev = d3d11_create_dev,
.set_hwframes = true,
- .static_pool = true,
.hwframes_refine = d3d_hwframes_refine,
- .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}
- },
.delay_queue = HWDEC_DELAY_QUEUE_COUNT,
};
diff --git a/video/decode/hw_dxva2.c b/video/decode/hw_dxva2.c
index d2fe5d6c15..ebfa12d1e1 100644
--- a/video/decode/hw_dxva2.c
+++ b/video/decode/hw_dxva2.c
@@ -171,14 +171,7 @@ const struct vd_lavc_hwdec mp_vd_lavc_dxva2 = {
.image_format = IMGFMT_DXVA2,
.generic_hwaccel = true,
.set_hwframes = true,
- .static_pool = true,
.hwframes_refine = d3d_hwframes_refine,
- .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}
- },
};
const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy = {
@@ -188,13 +181,6 @@ const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy = {
.generic_hwaccel = true,
.create_dev = d3d9_create_dev,
.set_hwframes = true,
- .static_pool = true,
.hwframes_refine = d3d_hwframes_refine,
- .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}
- },
.delay_queue = HWDEC_DELAY_QUEUE_COUNT,
};
diff --git a/video/decode/lavc.h b/video/decode/lavc.h
index e4db1f5f79..cf5485d3b6 100644
--- a/video/decode/lavc.h
+++ b/video/decode/lavc.h
@@ -99,16 +99,11 @@ struct vd_lavc_hwdec {
// efficiency by not blocking on the hardware pipeline by reading back
// immediately after decoding.
int delay_queue;
- // If true, AVCodecContext will destroy the underlying decoder.
- bool volatile_context;
int (*probe)(struct lavc_ctx *ctx, struct vd_lavc_hwdec *hwdec,
const char *codec);
int (*init)(struct lavc_ctx *ctx);
int (*init_decoder)(struct lavc_ctx *ctx, int w, int h);
void (*uninit)(struct lavc_ctx *ctx);
- // Note: if init_decoder is set, this will always use the values from the
- // last successful init_decoder call. Otherwise, it's up to you.
- struct mp_image *(*allocate_image)(struct lavc_ctx *ctx, int w, int h);
// Process the image returned by the libavcodec decoder.
struct mp_image *(*process_image)(struct lavc_ctx *ctx, struct mp_image *img);
// For copy hwdecs. If probing is true, don't log errors if unavailable.
@@ -126,12 +121,6 @@ struct vd_lavc_hwdec {
// If set, AVCodecContext.hw_frames_ctx will be initialized in get_format,
// and pixfmt_map must be non-NULL.
bool set_hwframes;
- // Array of pixfmt pairs. The first pixfmt is the AVCodecContext.sw_pix_fmt,
- // the second the required AVHWFramesContext.sw_format.
- const enum AVPixelFormat (*pixfmt_map)[2];
- // The generic hwaccel has a fixed pool size. Enough surfaces need to be
- // preallocated before decoding begins. If false, pool size is left to 0.
- bool static_pool;
};
enum {
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;