]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
[libav]: couple of fixes + temp modifications
authorlekma <lekmalek@gmail.com>
Wed, 31 Aug 2016 11:17:59 +0000 (13:17 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 28 Aug 2017 13:32:48 +0000 (15:32 +0200)
Makefile.ffmpeg
src/libav.c
src/transcoding/transcode/video.c
support/patches/ffmpeg.vaapi_encode.diff [new file with mode: 0644]

index 5d481683f329bbb82d6e155a2d087108259a7663..e131446f3a6ec5d9a557597f4352b90f607793ed 100644 (file)
@@ -556,6 +556,7 @@ EXTLIBS  += vaapi
 ENCODERS += h264_vaapi hevc_vaapi
 HWACCELS += mpeg2_vaapi h264_vaapi hevc_vaapi
 FILTERS  += scale_vaapi
+FFMPEG_DIFFS += ffmpeg.vaapi_encode.diff
 
 endif
 
index 3763cff45f895203205cb8a6825db45aed3b9316..dab9a658c1ba8008c4530a944fe8610e7220c526 100644 (file)
@@ -7,57 +7,43 @@
 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);
+  }
 }
 
 /**
@@ -116,7 +102,6 @@ streaming_component_type2codec_id(streaming_component_type_t type)
     codec_id = AV_CODEC_ID_DVB_TELETEXT;
     break;
   default:
-    codec_id = AV_CODEC_ID_NONE;
     break;
   }
 
@@ -182,7 +167,6 @@ codec_id2streaming_component_type(enum AVCodecID id)
     type = SCT_NONE;
     break;
   default:
-    type = SCT_UNKNOWN;
     break;
   }
 
@@ -209,11 +193,7 @@ libav_is_encoder(AVCodec *codec)
 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);
 }
 
@@ -223,8 +203,8 @@ libav_set_loglevel(void)
 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();
index 4245feb76faae3839fe0fdf8395df9df34a17bce..679d672123c99097dabf0266de5e511a8d2cafcf 100644 (file)
@@ -249,11 +249,11 @@ tvh_video_context_wrap(TVHContext *self, AVPacket *avpkt, th_pkt_t *pkt)
     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;
@@ -265,6 +265,8 @@ tvh_video_context_wrap(TVHContext *self, AVPacket *avpkt, th_pkt_t *pkt)
             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;
diff --git a/support/patches/ffmpeg.vaapi_encode.diff b/support/patches/ffmpeg.vaapi_encode.diff
new file mode 100644 (file)
index 0000000..599dac7
--- /dev/null
@@ -0,0 +1,61 @@
+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]));
+     }