Browse Source

lavc/mediacodec: use AVMediaCodecDeviceContext hw_device_ctx if set

Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
tags/n4.0
Aman Gupta Matthieu Bouron 8 years ago
parent
commit
8bf4e6d3ce
4 changed files with 20 additions and 4 deletions
  1. +3
    -0
      doc/APIchanges
  2. +3
    -2
      libavcodec/mediacodecdec.c
  3. +13
    -1
      libavcodec/mediacodecdec_common.c
  4. +1
    -1
      libavcodec/version.h

+ 3
- 0
doc/APIchanges View File

@@ -15,6 +15,9 @@ libavutil: 2017-10-21

API changes, most recent first:

2017-xx-xx - xxxxxxx - lavc 58.8.100 - avcodec.h
The MediaCodec decoders now support AVCodecContext.hw_device_ctx.

2017-xx-xx - xxxxxxx - lavu 56.6.100 - hwcontext.h hwcontext_mediacodec.h
Add AV_HWDEVICE_TYPE_MEDIACODEC and a new installed header with
MediaCodec-specific hwcontext definitions.


+ 3
- 2
libavcodec/mediacodecdec.c View File

@@ -520,8 +520,9 @@ static const AVCodecHWConfigInternal *mediacodec_hw_configs[] = {
&(const AVCodecHWConfigInternal) {
.public = {
.pix_fmt = AV_PIX_FMT_MEDIACODEC,
.methods = AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
.device_type = AV_HWDEVICE_TYPE_NONE,
.methods = AV_CODEC_HW_CONFIG_METHOD_AD_HOC |
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX,
.device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
},
.hwaccel = NULL,
},


+ 13
- 1
libavcodec/mediacodecdec_common.c View File

@@ -24,6 +24,7 @@
#include <sys/types.h>

#include "libavutil/common.h"
#include "libavutil/hwcontext_mediacodec.h"
#include "libavutil/mem.h"
#include "libavutil/log.h"
#include "libavutil/pixfmt.h"
@@ -476,7 +477,18 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s,
if (pix_fmt == AV_PIX_FMT_MEDIACODEC) {
AVMediaCodecContext *user_ctx = avctx->hwaccel_context;

if (user_ctx && user_ctx->surface) {
if (avctx->hw_device_ctx) {
AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)(avctx->hw_device_ctx->data);
if (device_ctx->type == AV_HWDEVICE_TYPE_MEDIACODEC) {
if (device_ctx->hwctx) {
AVMediaCodecDeviceContext *mediacodec_ctx = (AVMediaCodecDeviceContext *)device_ctx->hwctx;
s->surface = ff_mediacodec_surface_ref(mediacodec_ctx->surface, avctx);
av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface);
}
}
}

if (!s->surface && user_ctx && user_ctx->surface) {
s->surface = ff_mediacodec_surface_ref(user_ctx->surface, avctx);
av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface);
}


+ 1
- 1
libavcodec/version.h View File

@@ -28,7 +28,7 @@
#include "libavutil/version.h"

#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 7
#define LIBAVCODEC_VERSION_MINOR 8
#define LIBAVCODEC_VERSION_MICRO 100

#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \


Loading…
Cancel
Save