History

lavc/mediacodec: use AVMediaCodecDeviceContext hw_device_ctx if set

Aman Gupta committed 8 years ago

Commit 8bf4e6d1 parent e4d9f054 files · +20 −4Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavcodec/mediacodecdec.c +3 −2
  3. libavcodec/mediacodecdec_common.c +13 −1
  4. libavcodec/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2017-10-21 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2017-xx-xx - xxxxxxx - lavc 58.8.100 - avcodec.h
19+ The MediaCodec decoders now support AVCodecContext.hw_device_ctx.
20+
1821 2017-xx-xx - xxxxxxx - lavu 56.6.100 - hwcontext.h hwcontext_mediacodec.h
1922 Add AV_HWDEVICE_TYPE_MEDIACODEC and a new installed header with
2023 MediaCodec-specific hwcontext definitions.
libavcodec/mediacodecdec.c+3−2
@@ -520,8 +520,9 @@ static const AVCodecHWConfigInternal *mediacodec_hw_configs[] = { · 519 unmodified lines
520520 &(const AVCodecHWConfigInternal) {
521521 .public = {
522522 .pix_fmt = AV_PIX_FMT_MEDIACODEC,
523− .methods = AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
524− .device_type = AV_HWDEVICE_TYPE_NONE,
523+ .methods = AV_CODEC_HW_CONFIG_METHOD_AD_HOC |
524+ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX,
525+ .device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
525526 },
526527 .hwaccel = NULL,
527528 },
libavcodec/mediacodecdec_common.c+13−1
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include <sys/types.h>
2525
2626 #include "libavutil/common.h"
27+#include "libavutil/hwcontext_mediacodec.h"
2728 #include "libavutil/mem.h"
2829 #include "libavutil/log.h"
2930 #include "libavutil/pixfmt.h"
@@ -476,7 +477,18 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s, · 446 unmodified lines
476477 if (pix_fmt == AV_PIX_FMT_MEDIACODEC) {
477478 AVMediaCodecContext *user_ctx = avctx->hwaccel_context;
478479
479− if (user_ctx && user_ctx->surface) {
480+ if (avctx->hw_device_ctx) {
481+ AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)(avctx->hw_device_ctx->data);
482+ if (device_ctx->type == AV_HWDEVICE_TYPE_MEDIACODEC) {
483+ if (device_ctx->hwctx) {
484+ AVMediaCodecDeviceContext *mediacodec_ctx = (AVMediaCodecDeviceContext *)device_ctx->hwctx;
485+ s->surface = ff_mediacodec_surface_ref(mediacodec_ctx->surface, avctx);
486+ av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface);
487+ }
488+ }
489+ }
490+
491+ if (!s->surface && user_ctx && user_ctx->surface) {
480492 s->surface = ff_mediacodec_surface_ref(user_ctx->surface, avctx);
481493 av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface);
482494 }
libavcodec/version.h+1−1
@@ -28,7 +28,7 @@ · 27 unmodified lines
2828 #include "libavutil/version.h"
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 58
31−#define LIBAVCODEC_VERSION_MINOR 7
31+#define LIBAVCODEC_VERSION_MINOR 8
3232 #define LIBAVCODEC_VERSION_MICRO 100
3333
3434 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t