MythTV/mythtv

lossless transcode aborts

Closed this issue · 4 comments

  • Platform:
    Linux mythbackend 6.5.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 7 09:00:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
  • MythTV version:

v35-Pre-331-g41b921c949

  • Package version:

  • Component:

mythtranscode

What steps will reproduce the bug?

See attached.

mythtranscode.txt

How often does it reproduce? Is there a required condition?

I've only tried two so far and it has been consistent.

What is the expected behaviour?

What do you see instead?

Additional information

The error appears to be introduced in d4e6b3c. Works fine with previous commit, fails with d4e6b3c.

Try this:

diff --git a/mythtv/programs/mythtranscode/mpeg2fix.cpp b/mythtv/programs/mythtranscode/mpeg2fix.cpp
index 67cb340092..619d6cf97a 100644
--- a/mythtv/programs/mythtranscode/mpeg2fix.cpp
+++ b/mythtv/programs/mythtranscode/mpeg2fix.cpp
@@ -45,19 +45,6 @@ extern "C" {
 #define O_LARGEFILE 0
 #endif
 
-static void *my_malloc(unsigned size, [[maybe_unused]] mpeg2_alloc_t reason)
-{
-    if (size)
-    {
-#ifdef _WIN32
-        return _aligned_malloc( 64, size );
-#else
-        return aligned_alloc( 64, size );
-#endif
-    }
-    return nullptr;
-}
-
 static void my_av_print([[maybe_unused]] void *ptr,
                         int level, const char* fmt, va_list vl)
 {
@@ -266,7 +253,6 @@ MPEG2fixup::MPEG2fixup(const QString &inf, const QString &outf,
         m_useSecondary = true;
     }
 
-    mpeg2_malloc_hooks(my_malloc, nullptr);
     m_headerDecoder = mpeg2_init();
     m_imgDecoder = mpeg2_init();
 

@linuxdude42 aligned_alloc() requires size % alignment == 0 which the prior version did not. If that additional restriction was acceptable, free would need to be passed to mpeg2_malloc_hooks() instead of nullptr, otherwise libmpeg2 looks at the address prior to the one returned (which is a segmentation fault with aligned_alloc()) for a void* that points to the beginning of the allocated memory for use in free(). However, the previous version of my_malloc() is just a verbatim copy of what libmythmpeg2/alloc.c does if mpeg2_malloc_hooks() was not called, so we should just use the version from libmpeg2. (I don't know why my_malloc() ever existed since the version in libmpeg2 was first and neither have changed since then.)

The above changes worked for me.

Thanks

Thanks for the research, Scott.