]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
muxer configuration cleanups, add 'dvbsub reorder' for matroska profile
authorJaroslav Kysela <perex@perex.cz>
Mon, 22 May 2017 13:22:03 +0000 (15:22 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 22 May 2017 14:16:53 +0000 (16:16 +0200)
src/muxer.h
src/muxer/muxer_audioes.c
src/muxer/muxer_mkv.c
src/muxer/muxer_pass.c
src/profile.c
src/profile.h

index b2e442c6828af67efd07c660ec2e3e4f1379bdee..209f6696a6a78486daa8c65dc5ced81d823becc3 100644 (file)
@@ -53,23 +53,33 @@ typedef enum {
 /* Muxer configuration used when creating a muxer. */
 typedef struct muxer_config {
   int                  m_type; /* MC_* */
-
-  int                  m_rewrite_pat;
-  int                  m_rewrite_pmt;
-  int                  m_rewrite_sdt;
-  int                  m_rewrite_eit;
   int                  m_cache;
 
-  int                  m_force_type;
-  int                  m_index;
-
-/* 
- * directory_permissions should really be in dvr.h as it's not really needed for the muxer
- * but it's kept with file_permissions for neatness
- */
-
+  /*
+   * directory_permissions should really be in dvr.h as it's not really
+   * needed for the muxer, but it's kept with file_permissions for neatness
+   */
   int                  m_file_permissions;
   int                  m_directory_permissions; 
+
+  /*
+   * type specific section
+   */
+  union {
+    struct {
+      int              m_rewrite_pat;
+      int              m_rewrite_pmt;
+      int              m_rewrite_sdt;
+      int              m_rewrite_eit;
+    } pass;
+    struct {
+      int              m_dvbsub_reorder;
+    } mkv;
+    struct {
+      int              m_force_type;
+      int              m_index;
+    } audioes;
+  } u;
 } muxer_config_t;
 
 struct muxer;
index 79e3810d988c37c73609f0f1598453bfc3df731a..d4422a3e358b695cd1fe5ba11447ee1eb18fdc2b 100644 (file)
@@ -79,14 +79,13 @@ audioes_get_component(muxer_t *m, const struct streaming_start *ss)
 
   for (i = count = 0; i < ss->ss_num_components;i++) {
     ssc = &ss->ss_components[i];
-
     if ((!ssc->ssc_disabled) && (SCT_ISAUDIO(ssc->ssc_type))) {
-      if (m->m_config.m_force_type != MC_UNKNOWN) {
+      if (m->m_config.u.audioes.m_force_type != MC_UNKNOWN) {
         mc = audioes_muxer_type(ssc->ssc_type);
-        if (m->m_config.m_force_type != mc)
+        if (m->m_config.u.audioes.m_force_type != mc)
           continue;
       }
-      if (m->m_config.m_index == count)
+      if (m->m_config.u.audioes.m_index == count)
         return ssc;
       count++;
     }
@@ -104,8 +103,8 @@ audioes_muxer_mime(muxer_t *m, const struct streaming_start *ss)
   muxer_container_type_t mc = MC_UNKNOWN;
   const streaming_start_component_t *ssc;
 
-  if (m->m_config.m_force_type != MC_UNKNOWN)
-    return muxer_container_type2mime(m->m_config.m_force_type, 0);
+  if (m->m_config.u.audioes.m_force_type != MC_UNKNOWN)
+    return muxer_container_type2mime(m->m_config.u.audioes.m_force_type, 0);
 
   ssc = audioes_get_component(m, ss);
   if (ssc)
index 1510d3637dc826db7be07bff709819a9d998827a..f351e8ddef337bba4483a8b91595208f375934b1 100644 (file)
@@ -131,6 +131,7 @@ typedef struct mk_muxer {
   char *title;
 
   int webm;
+  int dvbsub_reorder;
 
   struct th_pktref_queue holdq;
 } mk_muxer_t;
@@ -1132,7 +1133,9 @@ mk_mux_write_pkt(mk_muxer_t *mk, th_pkt_t *pkt)
     return mk->error;
   }
 
-  if (pkt->pkt_type == SCT_DVBSUB && pts_diff(pkt->pkt_pcr, pkt->pkt_pts) > 90000) {
+  if (mk->dvbsub_reorder &&
+      pkt->pkt_type == SCT_DVBSUB &&
+      pts_diff(pkt->pkt_pcr, pkt->pkt_pts) > 90000) {
     tvhtrace(LS_MKV, "insert pkt to holdq: pts %"PRId64", pcr %"PRId64", diff %"PRId64"\n", pkt->pkt_pcr, pkt->pkt_pts, pts_diff(pkt->pkt_pcr, pkt->pkt_pts));
     pktref_enqueue_sorted(&mk->holdq, pkt, mk_pktref_cmp);
     return mk->error;
@@ -1526,6 +1529,7 @@ mkv_muxer_create(const muxer_config_t *m_cfg)
   mk->m_close        = mkv_muxer_close;
   mk->m_destroy      = mkv_muxer_destroy;
   mk->webm           = m_cfg->m_type == MC_WEBM;
+  mk->dvbsub_reorder = m_cfg->u.mkv.m_dvbsub_reorder;
   mk->fd             = -1;
 
   TAILQ_INIT(&mk->holdq);
index d4a228e6fc0bcacaa1072a35e5be264684f59dca..74008ffa73c388a6b85882491aea60ac3bfc50ec 100644 (file)
@@ -307,8 +307,8 @@ pass_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss)
 
   pm->pm_service_id = ss->ss_service_id;
   pm->pm_pmt_pid    = ss->ss_pmt_pid;
-  pm->pm_rewrite_sdt = !!pm->m_config.m_rewrite_sdt;
-  pm->pm_rewrite_eit = !!pm->m_config.m_rewrite_eit;
+  pm->pm_rewrite_sdt = !!pm->m_config.u.pass.m_rewrite_sdt;
+  pm->pm_rewrite_eit = !!pm->m_config.u.pass.m_rewrite_eit;
 
   for(i=0; i < ss->ss_num_components; i++) {
     ssc = &ss->ss_components[i];
@@ -325,7 +325,7 @@ pass_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss)
   }
 
 
-  if (pm->m_config.m_rewrite_pmt) {
+  if (pm->m_config.u.pass.m_rewrite_pmt) {
 
     if (pm->pm_ss)
       streaming_start_unref(pm->pm_ss);
@@ -440,7 +440,7 @@ pass_muxer_write_ts(muxer_t *m, pktbuf_t *pb)
   size_t  len = pktbuf_len(pb), len2;
   
   /* Rewrite PAT/PMT in operation */
-  if (pm->m_config.m_rewrite_pat || pm->m_config.m_rewrite_pmt ||
+  if (pm->m_config.u.pass.m_rewrite_pat || pm->m_config.u.pass.m_rewrite_pmt ||
       pm->pm_rewrite_sdt || pm->pm_rewrite_eit) {
 
     for (tsb = pktbuf_ptr(pb), len2 = pktbuf_len(pb), len = 0;
@@ -450,8 +450,8 @@ pass_muxer_write_ts(muxer_t *m, pktbuf_t *pb)
       l = mpegts_word_count(tsb, len2, 0x001FFF00);
 
       /* Process */
-      if ( (pm->m_config.m_rewrite_pat && pid == DVB_PAT_PID) ||
-           (pm->m_config.m_rewrite_pmt && pid == pm->pm_pmt_pid) ||
+      if ( (pm->m_config.u.pass.m_rewrite_pat && pid == DVB_PAT_PID) ||
+           (pm->m_config.u.pass.m_rewrite_pmt && pid == pm->pm_pmt_pid) ||
            (pm->pm_rewrite_sdt && pid == DVB_SDT_PID) ||
            (pm->pm_rewrite_eit && pid == DVB_EIT_PID) ) {
 
index 8d246481bd09a57fe4dccc8fce03c0fa74daf1aa..3641672751de2f6e10d967581450cba6012792b2 100644 (file)
@@ -1182,10 +1182,10 @@ profile_mpegts_pass_reopen(profile_chain_t *prch,
     memset(&c, 0, sizeof(c));
   if (c.m_type != MC_RAW)
     c.m_type = MC_PASS;
-  c.m_rewrite_pat = pro->pro_rewrite_pat;
-  c.m_rewrite_pmt = pro->pro_rewrite_pmt;
-  c.m_rewrite_sdt = pro->pro_rewrite_sdt;
-  c.m_rewrite_eit = pro->pro_rewrite_eit;
+  c.u.pass.m_rewrite_pat = pro->pro_rewrite_pat;
+  c.u.pass.m_rewrite_pmt = pro->pro_rewrite_pmt;
+  c.u.pass.m_rewrite_sdt = pro->pro_rewrite_sdt;
+  c.u.pass.m_rewrite_eit = pro->pro_rewrite_eit;
 
   assert(!prch->prch_muxer);
   prch->prch_muxer = muxer_create(&c);
@@ -1259,6 +1259,16 @@ const idclass_t profile_matroska_class =
       .def.i    = 0,
       .group    = 2
     },
+    {
+      .type     = PT_BOOL,
+      .id       = "dvbsub_reorder",
+      .name     = N_("Reorder DVBSUB"),
+      .desc     = N_("Reorder DVB subtitle packets."),
+      .off      = offsetof(profile_matroska_t, pro_dvbsub_reorder),
+      .opts     = PO_ADVANCED,
+      .def.i    = 1,
+      .group    = 2
+    },
     { }
   }
 };
@@ -1279,6 +1289,8 @@ profile_matroska_reopen(profile_chain_t *prch,
   if (pro->pro_webm)
     c.m_type = MC_WEBM;
 
+  c.u.mkv.m_dvbsub_reorder = pro->pro_dvbsub_reorder;
+
   assert(!prch->prch_muxer);
   prch->prch_muxer = muxer_create(&c);
   return 0;
@@ -1319,6 +1331,7 @@ profile_matroska_builder(void)
   pro->pro_reopen = profile_matroska_reopen;
   pro->pro_open   = profile_matroska_open;
   pro->pro_get_mc = profile_matroska_get_mc;
+  pro->pro_dvbsub_reorder = 1;
   return (profile_t *)pro;
 }
 
@@ -1386,8 +1399,8 @@ profile_audio_reopen(profile_chain_t *prch,
   else
     memset(&c, 0, sizeof(c));
   c.m_type = pro->pro_mc != MC_UNKNOWN ? pro->pro_mc : MC_MPEG2AUDIO;
-  c.m_force_type = pro->pro_mc;
-  c.m_index = pro->pro_index;
+  c.u.audioes.m_force_type = pro->pro_mc;
+  c.u.audioes.m_index = pro->pro_index;
 
   assert(!prch->prch_muxer);
   prch->prch_muxer = muxer_create(&c);
@@ -1830,23 +1843,23 @@ static htsmsg_t *
 profile_class_vcodec_preset_list(void *o, const char *lang)
 {
   static const struct strtab_str tab[] = {
-    {N_("ultrafast: h264 / h265")           , "ultrafast" },
-    {N_("superfast: h264 / h265")           , "superfast" },
-    {N_("veryfast: h264 / h265 / qsv(h264)")        , "veryfast"  },
-    {N_("faster: h264 / h265 / qsv(h264)")          , "faster"    },
-    {N_("fast: h264 / h265 / qsv(h264 / h265)")             , "fast"      },
-    {N_("medium: h264 / h265 / qsv(h264 / h265)")           , "medium"    },
-    {N_("slow: h264 / h265 / qsv(h264 / h265)")             , "slow"      },
-    {N_("slower: h264 / h265 / qsv(h264)")          , "slower"    },
-    {N_("veryslow: h264 / h265 / qsv(h264)")        , "veryslow"  },
-    {N_("placebo: h264 / h265")             , "placebo"   },
-    {N_("hq: nvenc(h264 / h265)")           , "hq"        },
-    {N_("hp: nvenc(h264 / h265)")           , "hp"        },
-    {N_("bd: nvenc(h264 / h265)")           , "bd"        },
-    {N_("ll: nvenc(h264 / h265)")           , "ll"        },
-    {N_("llhq: nvenc(h264 / h265)")     , "llhq"      },
-    {N_("llhp: nvenc(h264 / h265)")     , "llhp"      },
-    {N_("default: nvenc(h264 / h265)")  , "default"   }
+    {N_("ultrafast: h264 / h265")                    , "ultrafast" },
+    {N_("superfast: h264 / h265")                    , "superfast" },
+    {N_("veryfast: h264 / h265 / qsv(h264)")         , "veryfast"  },
+    {N_("faster: h264 / h265 / qsv(h264)")           , "faster"    },
+    {N_("fast: h264 / h265 / qsv(h264 / h265)")      , "fast"      },
+    {N_("medium: h264 / h265 / qsv(h264 / h265)")    , "medium"    },
+    {N_("slow: h264 / h265 / qsv(h264 / h265)")      , "slow"      },
+    {N_("slower: h264 / h265 / qsv(h264)")           , "slower"    },
+    {N_("veryslow: h264 / h265 / qsv(h264)")         , "veryslow"  },
+    {N_("placebo: h264 / h265")                      , "placebo"   },
+    {N_("hq: nvenc(h264 / h265)")                    , "hq"        },
+    {N_("hp: nvenc(h264 / h265)")                    , "hp"        },
+    {N_("bd: nvenc(h264 / h265)")                    , "bd"        },
+    {N_("ll: nvenc(h264 / h265)")                    , "ll"        },
+    {N_("llhq: nvenc(h264 / h265)")                  , "llhq"      },
+    {N_("llhp: nvenc(h264 / h265)")                  , "llhp"      },
+    {N_("default: nvenc(h264 / h265)")               , "default"   }
   };
   return strtab2htsmsg_str(tab, 1, lang);
 }
index cd518c52e76948f8da470c98a252bdb34b5a6567..1e03d230d48e87f7050bf0b758579e48c830a015 100644 (file)
@@ -134,6 +134,7 @@ typedef struct profile {
   int pro_ca_timeout;
   int pro_swservice;
   int pro_svfilter;
+  int pro_dvbsub_reorder;
 
   void (*pro_free)(struct profile *pro);
   void (*pro_conf_changed)(struct profile *pro);