summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-01-04 21:19:40 +0100
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-01-04 21:19:40 +0100
commitb14e0e8c0fde976581fca7dc9975970c884d352a (patch)
treeba6ed34ec8d1992dfcceb65400b63c5b764ebe5e /modules
parent2e31901b6faf0bdef07cb69b76da1daa418318a5 (diff)
avcodec: configure h264 decoder by name
patch was written by @hargut fixes https://github.com/alfredh/baresip/pull/198
Diffstat (limited to 'modules')
-rw-r--r--modules/avcodec/avcodec.c22
-rw-r--r--modules/avcodec/avcodec.h1
-rw-r--r--modules/avcodec/decode.c19
3 files changed, 37 insertions, 5 deletions
diff --git a/modules/avcodec/avcodec.c b/modules/avcodec/avcodec.c
index b5b46f0..307b774 100644
--- a/modules/avcodec/avcodec.c
+++ b/modules/avcodec/avcodec.c
@@ -32,7 +32,8 @@
* Config options:
*
\verbatim
- avcodec_h264enc <NAME> ; e.g. nvenc_h264, h264_videotoolbox
+ avcodec_h264enc <NAME> ; e.g. h264_nvenc, h264_videotoolbox
+ avcodec_h264dec <NAME> ; e.g. h264_cuvid, h264_vda, h264_qsv
\endverbatim
*
* References:
@@ -48,6 +49,7 @@
const uint8_t h264_level_idc = 0x0c;
AVCodec *avcodec_h264enc; /* optinal; specified H.264 encoder */
+AVCodec *avcodec_h264dec; /* optinal; specified H.264 decoder */
int avcodec_resolve_codecid(const char *s)
@@ -182,6 +184,7 @@ static struct vidcodec mpg4 = {
static int module_init(void)
{
char h264enc[64];
+ char h264dec[64];
#ifdef USE_X264
debug("avcodec: x264 build %d\n", X264_BUILD);
@@ -195,8 +198,23 @@ static int module_init(void)
avcodec_register_all();
- if (avcodec_find_decoder(AV_CODEC_ID_H264))
+ if (0 == conf_get_str(conf_cur(), "avcodec_h264dec",
+ h264dec, sizeof(h264dec))) {
+
+ info("avcodec: using h264 decoder by name (%s)\n", h264dec);
+
+ avcodec_h264dec = avcodec_find_decoder_by_name(h264dec);
+ if (!avcodec_h264dec) {
+ warning("avcodec: h264 decoder not found (%s)\n",
+ h264dec);
+ return ENOENT;
+ }
vidcodec_register(&h264);
+ }
+ else {
+ if (avcodec_find_decoder(AV_CODEC_ID_H264))
+ vidcodec_register(&h264);
+ }
if (avcodec_find_decoder(AV_CODEC_ID_H263))
vidcodec_register(&h263);
diff --git a/modules/avcodec/avcodec.h b/modules/avcodec/avcodec.h
index 601a402..f3a2b70 100644
--- a/modules/avcodec/avcodec.h
+++ b/modules/avcodec/avcodec.h
@@ -18,6 +18,7 @@
extern const uint8_t h264_level_idc;
extern AVCodec *avcodec_h264enc;
+extern AVCodec *avcodec_h264dec;
/*
diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c
index 9b24586..6416662 100644
--- a/modules/avcodec/decode.c
+++ b/modules/avcodec/decode.c
@@ -57,9 +57,18 @@ static int init_decoder(struct viddec_state *st, const char *name)
if (codec_id == AV_CODEC_ID_NONE)
return EINVAL;
- st->codec = avcodec_find_decoder(codec_id);
- if (!st->codec)
- return ENOENT;
+ /*
+ * Special handling of H.264 decoder
+ */
+ if (codec_id == AV_CODEC_ID_H264 && avcodec_h264dec) {
+ st->codec = avcodec_h264dec;
+ info("avcodec: h264 decoder activated\n");
+ }
+ else {
+ st->codec = avcodec_find_decoder(codec_id);
+ if (!st->codec)
+ return ENOENT;
+ }
#if LIBAVCODEC_VERSION_INT >= ((52<<16)+(92<<8)+0)
st->ctx = avcodec_alloc_context3(st->codec);
@@ -212,6 +221,10 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame,
frame->fmt = VID_FMT_YUV420P;
break;
+ case AV_PIX_FMT_NV12:
+ frame->fmt = VID_FMT_NV12;
+ break;
+
default:
warning("avcodec: decode: bad pixel format"
" (%i) (%s)\n",