summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-04-25 12:12:40 +0200
committerwm4 <wm4@nowhere>2016-04-25 12:23:38 +0200
commit6a1814dfb85a18ddfbf9a99c6eabde2978b3274d (patch)
tree51210969843f6fcc5f211330cc60322eb8af4ffa /video/decode
parent7e3d8e7134096972989c8fae636e29af10ccaa79 (diff)
downloadmpv-6a1814dfb85a18ddfbf9a99c6eabde2978b3274d.tar.bz2
mpv-6a1814dfb85a18ddfbf9a99c6eabde2978b3274d.tar.xz
vd_lavc: make image_format hwdec field optional
For Mediacodec in particular we don't care about the format. It can just decode to whatever it wants. The only case we would care about is it not returning an opaque format if we don't have proper interop, but libavcodec always returns non-opaque formats by default.
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/vd_lavc.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 24c98f2ef1..7658842711 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -137,7 +137,6 @@ static const struct vd_lavc_hwdec mp_vd_lavc_rpi = {
static const struct vd_lavc_hwdec mp_vd_lavc_mediacodec = {
.type = HWDEC_MEDIACODEC,
.lavc_suffix = "_mediacodec",
- .image_format = IMGFMT_NV12,
};
static const struct vd_lavc_hwdec *const hwdec_list[] = {
@@ -464,8 +463,9 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
goto error;
if (ctx->hwdec) {
- avctx->thread_count = 1;
- avctx->get_format = get_format_hwdec;
+ avctx->thread_count = 1;
+ 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)
@@ -620,31 +620,29 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx,
ctx->hwdec_request_reinit |= ctx->hwdec_failed;
ctx->hwdec_failed = false;
- if (ctx->hwdec->image_format) {
- for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++) {
- if (ctx->hwdec->image_format == pixfmt2imgfmt(fmt[i])) {
- // There could be more reasons for a change, and it's possible
- // that we miss some. (Might also depend on the hwaccel type.)
- bool change =
- ctx->hwdec_w != avctx->coded_width ||
- ctx->hwdec_h != avctx->coded_height ||
- ctx->hwdec_fmt != ctx->hwdec->image_format ||
- ctx->hwdec_profile != avctx->profile ||
- ctx->hwdec_request_reinit;
- ctx->hwdec_w = avctx->coded_width;
- ctx->hwdec_h = avctx->coded_height;
- ctx->hwdec_fmt = ctx->hwdec->image_format;
- ctx->hwdec_profile = avctx->profile;
- ctx->hwdec_request_reinit = false;
- if (change && ctx->hwdec->init_decoder) {
- if (ctx->hwdec->init_decoder(ctx, ctx->hwdec_w, ctx->hwdec_h) < 0)
- {
- ctx->hwdec_fmt = 0;
- break;
- }
+ for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++) {
+ if (ctx->hwdec->image_format == pixfmt2imgfmt(fmt[i])) {
+ // There could be more reasons for a change, and it's possible
+ // that we miss some. (Might also depend on the hwaccel type.)
+ bool change =
+ ctx->hwdec_w != avctx->coded_width ||
+ ctx->hwdec_h != avctx->coded_height ||
+ ctx->hwdec_fmt != ctx->hwdec->image_format ||
+ ctx->hwdec_profile != avctx->profile ||
+ ctx->hwdec_request_reinit;
+ ctx->hwdec_w = avctx->coded_width;
+ ctx->hwdec_h = avctx->coded_height;
+ ctx->hwdec_fmt = ctx->hwdec->image_format;
+ ctx->hwdec_profile = avctx->profile;
+ ctx->hwdec_request_reinit = false;
+ if (change && ctx->hwdec->init_decoder) {
+ if (ctx->hwdec->init_decoder(ctx, ctx->hwdec_w, ctx->hwdec_h) < 0)
+ {
+ ctx->hwdec_fmt = 0;
+ break;
}
- return fmt[i];
}
+ return fmt[i];
}
}