ENCODERS += h264_vaapi hevc_vaapi
HWACCELS += mpeg2_vaapi h264_vaapi hevc_vaapi
FILTERS += scale_vaapi
+FFMPEG_DIFFS += ffmpeg.vaapi_encode.diff
endif
static void
libav_log_callback(void *ptr, int level, const char *fmt, va_list vl)
{
- char message[8192];
- char *nl;
- char *l;
+ int severity = LOG_TVH_NOTIFY;
- //if ((level == AV_LOG_DEBUG) && !(tvhlog_options & TVHLOG_OPT_LIBAV))
- // return;
-
- memset(message, 0, sizeof(message));
- vsnprintf(message, sizeof(message), fmt, vl);
-
- l = message;
-
- if(level == AV_LOG_DEBUG)
+ if (level != AV_LOG_QUIET &&
+ ((level <= AV_LOG_INFO) || (tvhlog_options & TVHLOG_OPT_LIBAV))) {
+ switch(level) {
+ case AV_LOG_TRACE:
#if ENABLE_TRACE
- level = LOG_TRACE;
-#else
- level = LOG_DEBUG;
+ severity |= LOG_TRACE;
+ break;
#endif
- else if(level == AV_LOG_VERBOSE)
- level = LOG_DEBUG;
- else if(level == AV_LOG_INFO)
- level = LOG_INFO;
- else if(level == AV_LOG_WARNING)
- level = LOG_WARNING;
- else if(level == AV_LOG_ERROR)
- level = LOG_ERR;
- else if(level == AV_LOG_FATAL)
- level = LOG_CRIT;
- else if(level == AV_LOG_PANIC)
- level = LOG_EMERG;
-
- if (level == LOG_INFO) {
- if (!strncmp(message, "--prefix=/", 10))
- return;
- }
-
- while(l < message + sizeof(message)) {
- nl = strstr(l, "\n");
- if(nl)
- *nl = '\0';
-
- if(!strlen(l))
- break;
-
- tvhlog(level, LS_LIBAV, "%s", l);
-
- if(!nl)
- break;
-
- l = nl + 1;
+ case AV_LOG_DEBUG:
+ case AV_LOG_VERBOSE:
+ severity |= LOG_DEBUG;
+ break;
+ case AV_LOG_INFO:
+ severity |= LOG_INFO;
+ break;
+ case AV_LOG_WARNING:
+ severity |= LOG_WARNING;
+ break;
+ case AV_LOG_ERROR:
+ severity |= LOG_ERR;
+ break;
+ case AV_LOG_FATAL:
+ severity |= LOG_CRIT;
+ break;
+ case AV_LOG_PANIC:
+ severity |= LOG_EMERG;
+ break;
+ default:
+ break;
}
+ va_list ap;
+ va_copy(ap, vl);
+ tvhlogv(__FILE__, __LINE__, severity, LS_LIBAV, fmt, &ap);
+ va_end(ap);
+ }
}
/**
codec_id = AV_CODEC_ID_DVB_TELETEXT;
break;
default:
- codec_id = AV_CODEC_ID_NONE;
break;
}
type = SCT_NONE;
break;
default:
- type = SCT_UNKNOWN;
break;
}
void
libav_set_loglevel(void)
{
- int level = AV_LOG_VERBOSE;
-
- //if (tvhlog_options & TVHLOG_OPT_LIBAV)
- // level = AV_LOG_DEBUG;
-
+ int level = (tvhlog_options & TVHLOG_OPT_LIBAV) ? AV_LOG_DEBUG : AV_LOG_INFO;
av_log_set_level(level);
}
void
libav_init(void)
{
- av_log_set_callback(libav_log_callback);
libav_set_loglevel();
+ av_log_set_callback(libav_log_callback);
av_register_all();
avformat_network_init();
avfilter_register_all();
if (qsdata && qsdata_size >= 5) {
pict_type = qsdata[4];
}
-#if FF_API_CODED_FRAME
+/*#if FF_API_CODED_FRAME
else if (self->oavctx->coded_frame) {
pict_type = self->oavctx->coded_frame->pict_type;
}
-#endif
+#endif*/
switch (pict_type) {
case AV_PICTURE_TYPE_I:
pkt->v.pkt_frametype = PKT_I_FRAME;
pkt->v.pkt_frametype = PKT_B_FRAME;
break;
default:
+ tvh_context_log(self, LOG_ERR, "unknown picture type: %d",
+ pict_type);
break;
}
pkt->pkt_duration = avpkt->duration;
--- /dev/null
+diff -urN ../ffmpeg-3.1.3.orig/libavcodec/vaapi_encode.c ./libavcodec/vaapi_encode.c
+--- ../ffmpeg-3.1.3.orig/libavcodec/vaapi_encode.c 2016-06-27 01:54:29.000000000 +0200
++++ ./libavcodec/vaapi_encode.c 2016-08-31 11:53:21.159413291 +0200
+@@ -26,6 +26,7 @@
+
+ #include "vaapi_encode.h"
+ #include "avcodec.h"
++#include "internal.h"
+
+ static const char *picture_type_name[] = { "IDR", "I", "P", "B" };
+
+@@ -395,7 +396,7 @@
+ VAAPIEncodeContext *ctx = avctx->priv_data;
+ VACodedBufferSegment *buf_list, *buf;
+ VAStatus vas;
+- int err;
++ int err, pict_type;
+
+ err = vaapi_encode_wait(avctx, pic);
+ if (err < 0)
+@@ -427,6 +428,28 @@
+
+ pkt->pts = pic->pts;
+
++ switch (pic->type) {
++ case PICTURE_TYPE_IDR:
++ case PICTURE_TYPE_I:
++ pict_type = AV_PICTURE_TYPE_I;
++ break;
++ case PICTURE_TYPE_P:
++ pict_type = AV_PICTURE_TYPE_P;
++ break;
++ case PICTURE_TYPE_B:
++ pict_type = AV_PICTURE_TYPE_B;
++ break;
++ default:
++ pict_type = AV_PICTURE_TYPE_NONE;
++ break;
++ }
++#if FF_API_CODED_FRAME
++FF_DISABLE_DEPRECATION_WARNINGS
++ avctx->coded_frame->pict_type = pict_type;
++FF_ENABLE_DEPRECATION_WARNINGS
++#endif
++ ff_side_data_set_encoder_stats(pkt, -1, NULL, 0, pict_type);
++
+ vas = vaUnmapBuffer(ctx->hwctx->display, pic->output_buffer);
+ if (vas != VA_STATUS_SUCCESS) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to unmap output buffers: "
+diff -urN ../ffmpeg-3.1.3.orig/libavcodec/vaapi_encode_h265.c ./libavcodec/vaapi_encode_h265.c
+--- ../ffmpeg-3.1.3.orig/libavcodec/vaapi_encode_h265.c 2016-08-09 00:53:26.000000000 +0200
++++ ./libavcodec/vaapi_encode_h265.c 2016-08-31 13:05:03.827533472 +0200
+@@ -300,7 +300,7 @@
+
+ u(6, mseq_var(vps_max_layer_id));
+ ue(mseq_var(vps_num_layer_sets_minus1));
+- for (i = 1; i <= mseq->vps_num_layer_sets_minus1; i++) {
++ for (i = 0; i <= mseq->vps_num_layer_sets_minus1; i++) {
+ for (j = 0; j < mseq->vps_max_layer_id; j++)
+ u(1, mseq_var(layer_id_included_flag[i][j]));
+ }