Segmentation Fault on Doctor Who Season 1, Disc 2, Title 4

Archive of historical bug reports.
Please use the GitHub link above to report issues.
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.

*******************************
Post Reply
zow
Posts: 1
Joined: Tue Apr 10, 2007 3:16 am

Segmentation Fault on Doctor Who Season 1, Disc 2, Title 4

Post by zow »

Okay, I've been able to encode all of Doctor Who, Season 1 ("First Series"), Region 1, except for one episode: Aliens of London -- it's Title 4 on the second disc. 18% of the way through it, HandBrake/MediaFork segmentation faults. On the GUI, I get the "HandBrake has unexpectedly closed" dialog. Here's the output from the CLI:
Isamu:/Volumes/MediaFork tv$ ./MediaForkCLI -u
MediaFork 0.8.0b1 (2007021100) - http://mediafork.dynalias.com/
Your version of MediaFork is up to date.
Isamu:/Volumes/MediaFork tv$ ./MediaForkCLI --format mp4 --input /Volumes/DVDs\ One/Doctor\ Who/First\ Series/Disc\ 2/E2501 --output ~/test.mp4 --title 4 --encoder x264 --deinterlace
MediaFork 0.8.0b1 (2007021100) - http://mediafork.dynalias.com/
2 CPUs detected
Opening /Volumes/DVDs One/Doctor Who/First Series/Disc 2/E2501...
Scanning title 4...
+ title 4:
+ vts 3, ttn 2, cells 0->14 (1107736 blocks)
+ duration: 00:45:03
+ size: 720x480, aspect: 1.78, 23.976 fps
+ autocrop: 0/0/0/0
+ chapters:
+ 1: cells 0->0, 15671 blocks, duration 00:00:38
+ 2: cells 1->1, 103212 blocks, duration 00:04:11
+ 3: cells 2->2, 85640 blocks, duration 00:03:29
+ 4: cells 3->3, 98915 blocks, duration 00:04:09
+ 5: cells 4->4, 76922 blocks, duration 00:03:07
+ 6: cells 5->5, 93258 blocks, duration 00:03:47
+ 7: cells 6->6, 96217 blocks, duration 00:03:54
+ 8: cells 7->7, 151134 blocks, duration 00:06:08
+ 9: cells 8->8, 81537 blocks, duration 00:03:19
+ 10: cells 9->9, 93369 blocks, duration 00:03:47
+ 11: cells 10->10, 91343 blocks, duration 00:03:43
+ 12: cells 11->11, 86104 blocks, duration 00:03:29
+ 13: cells 12->12, 16013 blocks, duration 00:00:38
+ 14: cells 13->14, 18401 blocks, duration 00:00:46
+ audio tracks:
+ 80bd, English (AC3) (5 ch), 48000Hz, 448000bps
+ 81bd, English (AC3) (2 ch), 48000Hz, 192000bps
+ subtitle tracks:
+ 20bd, English
No accelerated IMDCT transform found
Encoding: task 1 of 1, 18.41 % (23.13 fps, avg 21.09 fps, ETA 00h41m47s)Segmentation fault

Let's see, what else would anyone want to know:
-Version
HandBrake 0.7.1
MediaFork 0.8.0b1

-Date of download
HandBrake 0.7.1: 9 May 2006
MediaFork 0.8.0b1: 6 March 2007

-Platform (Mac, Linux, Windows)
Mac OS 10.4.8

-Settings (video encoder, picture dimensions, etc.)
I've tried every encoder and video format option for an mp4 container. Also tried a couple with an avi container. All did the same thing. Default audio & picture settings. Sometimes tried to deinterlace or encode at a 2k video rate, and again, it always crashes.

-Operating System version
10.4.8

-If possible, a crash report
See above

-DVD title
Doctor Who Season 1, Disc 2, Title 4

-What you were doing at the time besides encoding
I've had MtR and Lostify running at the same time, but when trying to find the source of the problem, I've let HB/MF be the only thing running.

-What other applications were running
Finder

-Whether or not the problem is reproducible (happens every time with the same settings/movie)
Perfectly

Oh -- this is also important: I thought this might be a rip issue, so I re-ripped the disc with MtR 2.6, same thing. So I got MtR 3.0b14 and tried it again, same thing (that's the rip that I tried all the different encoding variations with). So I tried encoding straight from the disc, same thing.

All my other discs are working so well -- it would be nice just to know if anyone else is having a problem with this title.

I'm a pretty good developer so, if necessary, I could get down and dirty with gdb, but I don't have the tool chains installed on my personal machines, so I'd really rather avoid that. If there's anything easier I could do first: like run a development build with tracing on and send back the trace file, I'd be happy to.
saintdev
Enlightened
Posts: 146
Joined: Wed Dec 20, 2006 4:17 am

Post by saintdev »

[Edit] Actually could you post the output of one of the crashes with the --verbose command enabled first?[/Edit]
I'm not sure about this one. I would need to get a trace to see what's going on, but unfortunately I don't have a Mac, I'm seeing if one of the devs that do can get you a debug build so we can get a little more info on this.
lhotka
Posts: 30
Joined: Fri Mar 09, 2007 9:49 pm

Ditto

Post by lhotka »

I've had this problem too. I got around it by using PQDVD on Windows for that one episode (which is how I get around all the MF crashes, missing tracks, and audio failures).

I'm *really* looking forward to the next release - I don't care about new features, will happily settle for a version that doesn't crash, has good audio, and doesn't have missing titles (like Disc 6 of the 3rd season of Trek TOS).
lhotka
Posts: 30
Joined: Fri Mar 09, 2007 9:49 pm

forgot details

Post by lhotka »

Sorry,

I should have added that I've also tried MTR 2.6, R14B, and direct - nothing works. I also used RipIt4Me on windows and had the same result in MF too - it's clearly something in the data itself, not something funky on the disk.

Don't misunderstand - I REALLY appreciate all your hard work - thanks!!!
saintdev
Enlightened
Posts: 146
Joined: Wed Dec 20, 2006 4:17 am

Post by saintdev »

Ihothka, since the OP is MIA, I have a few questions, are you able to use the CLI version of MediaFork? If so, could you post the command line you used, and the output with the -v switch enabled?I really would like to get to the bottom of this if we can.
lhotka
Posts: 30
Joined: Fri Mar 09, 2007 9:49 pm

I'll give it a go...

Post by lhotka »

I haven't tried the CLI interface yet, but will give it a go and post the results.
lhotka
Posts: 30
Joined: Fri Mar 09, 2007 9:49 pm

Sigh

Post by lhotka »

I apparently spoke too soon - don't see a CLI download for OSX. Is there one bundled in the DMG or do I need to build it?
saintdev
Enlightened
Posts: 146
Joined: Wed Dec 20, 2006 4:17 am

Post by saintdev »

Yes, it is bundled in the DMG, the name should be MediaForkCLI.
Nonsanity
Moderator
Posts: 46
Joined: Mon Feb 12, 2007 4:34 am

Post by Nonsanity »

I had this problem way back. I traced them trouble to the moment when the Doctor and Rose sit down to watch telly. The aspect ratio of the TV clip is different from the rest of the show. That seems to throw HandBrake for a loop.

I keep meaning to revisit the problem again. Perhaps the TV clip is it's own VOB and can be forced into the right aspect ratio...
epstewart
Experienced
Posts: 84
Joined: Thu Aug 09, 2007 9:17 pm

Post by epstewart »

I have also gotten nothing but "unexpectedly quit" errors each time I have pointed HandBrake 0.9.0 (or any earlier version) at the U.S. Doctor Who DVD set title, Aliens of London (Disc 2, Title 3). No matter what parameters I have tried for the conversion, HandBrake quits.

I've tried pointing HandBrake at the VIDEO_TS of this title created by Mac the Ripper. It doesn't help.

Today I tried using Roxio Crunch with the VIDEO_TS, and it worked. Crunch apparently uses QuickTime to do its codec conversions, and it looks to me like it also uses code from Apple's DVD Player to figure out the VIDEO_TS contents. HandBrake uses its own code for both functions, I gather.

I imagine something in that code is going off in the weeds on this particular title.

If any of the developers would like, I would be happy to do whatever they suggest to help pin this problem down.
tweder
Posts: 3
Joined: Tue Sep 18, 2007 10:37 pm

Post by tweder »

I'm having exactly the same problem. I've tried encoding this with every option under the sun, but it always seems to make HB choke.

Handbrake 0.9.0 on OS X v10.4.10 (Intel)
Using AppleTV preset with de-interlace set to Fast

I've also noticed in the subwindow for setting cropping/de-interlacing options, when paging through screens of the episode, one of the previews appears to be distorted colored garbage -- presumably this is on or about where the crash is occuring.

Provided is the output from Apple's crash reporting agent, I can also create output via Sampler.app or from the CLI if that helps any.

Code: Select all

Date/Time:      2007-09-18 16:26:12.125 -0600
OS Version:     10.4.10 (Build 8R2232)
Report Version: 4

Command: HandBrake
Path:    /Applications/HandBrake.app/Contents/MacOS/HandBrake
Parent:  WindowServer [65]

Version: 0.9.0 (2007081900)

PID:    337
Thread: 8

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_INVALID_ADDRESS (0x0001) at 0x1751f000

Thread 0:
0   libSystem.B.dylib              	0x90009cd7 mach_msg_trap + 7
1   com.apple.CoreFoundation       	0x9082d2b3 CFRunLoopRunSpecific + 2014
2   com.apple.CoreFoundation       	0x9082cace CFRunLoopRunInMode + 61
3   com.apple.HIToolbox            	0x92ded8d8 RunCurrentEventLoopInMode + 285
4   com.apple.HIToolbox            	0x92decfe2 ReceiveNextEventCommon + 385
5   com.apple.HIToolbox            	0x92dece39 BlockUntilNextEventMatchingListInMode + 81
6   com.apple.AppKit               	0x93293465 _DPSNextEvent + 572
7   com.apple.AppKit               	0x93293056 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 137
8   com.apple.AppKit               	0x9328cddb -[NSApplication run] + 512
9   com.apple.AppKit               	0x93280d2f NSApplicationMain + 573
10  org.m0k.handbrake              	0x00002472 _start + 216
11  org.m0k.handbrake              	0x00002399 start + 41

Thread 1:
0   libSystem.B.dylib              	0x90037b57 mach_wait_until + 7
1   libSystem.B.dylib              	0x9003a222 usleep + 82
2   org.m0k.handbrake              	0x0002a0a8 hb_snooze + 39 (ports.c:82)
3   org.m0k.handbrake              	0x0002094f thread_func + 352 (hb.c:912)
4   org.m0k.handbrake              	0x0002a6e8 hb_thread_func + 73 (ports.c:270)
5   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 2:
0   libSystem.B.dylib              	0x90026d5c kevent + 12
1   ...ple.CoreServices.CarbonCore 	0x90cb8c6c PrivateMPEntryPoint + 51
2   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 3:
0   libSystem.B.dylib              	0x900248c7 semaphore_wait_signal_trap + 7
1   ...ple.CoreServices.CarbonCore 	0x90cb8e11 MPWaitOnQueue + 198
2   com.apple.DesktopServices      	0x9271c953 TNodeSyncTask::SyncTaskProc(void*) + 143
3   ...ple.CoreServices.CarbonCore 	0x90cb8c6c PrivateMPEntryPoint + 51
4   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 4:
0   libSystem.B.dylib              	0x9003f6cf syscall_thread_switch + 7
1   com.apple.AppKit               	0x9336a682 -[NSUIHeartBeat _heartBeatThread:] + 1399
2   com.apple.Foundation           	0x927f52e0 forkThreadForFunction + 123
3   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 5:
0   libSystem.B.dylib              	0x90037b57 mach_wait_until + 7
1   libSystem.B.dylib              	0x9003a222 usleep + 82
2   org.m0k.handbrake              	0x0002a0a8 hb_snooze + 39 (ports.c:82)
3   org.m0k.handbrake              	0x0003405a work_func + 3788 (work.c:489)
4   org.m0k.handbrake              	0x0002a6e8 hb_thread_func + 73 (ports.c:270)
5   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 6:
0   libSystem.B.dylib              	0x90037b57 mach_wait_until + 7
1   libSystem.B.dylib              	0x9003a222 usleep + 82
2   org.m0k.handbrake              	0x0002a0a8 hb_snooze + 39 (ports.c:82)
3   org.m0k.handbrake              	0x001043d1 ReaderFunc + 672 (reader.c:129)
4   org.m0k.handbrake              	0x0002a6e8 hb_thread_func + 73 (ports.c:270)
5   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 7:
0   libSystem.B.dylib              	0x90037b57 mach_wait_until + 7
1   libSystem.B.dylib              	0x9003a222 usleep + 82
2   org.m0k.handbrake              	0x0002a0a8 hb_snooze + 39 (ports.c:82)
3   org.m0k.handbrake              	0x00103bbe MuxerFunc + 715 (muxcommon.c:144)
4   org.m0k.handbrake              	0x0002a6e8 hb_thread_func + 73 (ports.c:270)
5   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 8 Crashed:
0   <<00000000>> 	0xffff0884 __memcpy + 228 (cpu_capabilities.h:228)
1   org.m0k.handbrake              	0x00021b63 hb_libmpeg2_decode + 594 (decmpeg2.c:167)
2   org.m0k.handbrake              	0x00021ed4 decmpeg2Work + 102 (decmpeg2.c:388)
3   org.m0k.handbrake              	0x00033127 work_loop + 96 (work.c:667)
4   org.m0k.handbrake              	0x0002a6e8 hb_thread_func + 73 (ports.c:270)
5   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 9:
0   libSystem.B.dylib              	0x90037b57 mach_wait_until + 7
1   libSystem.B.dylib              	0x9003a222 usleep + 82
2   org.m0k.handbrake              	0x0002a0a8 hb_snooze + 39 (ports.c:82)
3   org.m0k.handbrake              	0x00033112 work_loop + 75 (work.c:658)
4   org.m0k.handbrake              	0x0002a6e8 hb_thread_func + 73 (ports.c:270)
5   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 10:
0   libSystem.B.dylib              	0x90009cd7 mach_msg_trap + 7
1   libSystem.B.dylib              	0x90024118 thread_create_running + 217
2   libSystem.B.dylib              	0x90024026 _pthread_setup + 230
3   libSystem.B.dylib              	0x90023c79 pthread_create + 1030

Thread 11:
0   libSystem.B.dylib              	0x90037b57 mach_wait_until + 7
1   libSystem.B.dylib              	0x9003a222 usleep + 82
2   org.m0k.handbrake              	0x0002a0a8 hb_snooze + 39 (ports.c:82)
3   org.m0k.handbrake              	0x00033112 work_loop + 75 (work.c:658)
4   org.m0k.handbrake              	0x0002a6e8 hb_thread_func + 73 (ports.c:270)
5   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 12:
0   libSystem.B.dylib              	0x90037b57 mach_wait_until + 7
1   libSystem.B.dylib              	0x9003a222 usleep + 82
2   org.m0k.handbrake              	0x0002a0a8 hb_snooze + 39 (ports.c:82)
3   org.m0k.handbrake              	0x00033112 work_loop + 75 (work.c:658)
4   org.m0k.handbrake              	0x0002a6e8 hb_thread_func + 73 (ports.c:270)
5   libSystem.B.dylib              	0x90024227 _pthread_body + 84

Thread 13:
0   org.m0k.handbrake              	0x0033efae get_ref_mmx + 141

Thread 8 crashed with X86 Thread State (32-bit):
  eax: 0xffff088b  ebx: 0x00021925  ecx: 0x00000070  edx: 0x00015180
  edi: 0x1b1765c0  esi: 0x1751f000  ebp: 0xb0424e38  esp: 0xb0424e30
   ss: 0x0000001f  efl: 0x00010206  eip: 0xffff0884   cs: 0x00000017
   ds: 0x0000001f   es: 0x0000001f   fs: 0x00000000   gs: 0x00000037

Binary Images Description:
    0x1000 -   0x494fff org.m0k.handbrake 0.9.0 (2007081900)	/Applications/HandBrake.app/Contents/MacOS/HandBrake
  0xa64000 -   0xa64fff com.growl.GrowlSafariLoader 1.0 (1.1)	/Library/InputManagers/GrowlSafari/GrowlSafariLoader.bundle/Contents/MacOS/GrowlSafariLoader
  0xa69000 -   0xa69fff com.ksuther.chaxloader ??? (1.4.8)	/Library/InputManagers/Chax/Chax.bundle/Contents/MacOS/Chax
  0xa6e000 -   0xa6efff org.xlife.InquisitorLoader 3.0 (46)	/Users/scott/Library/InputManagers/Inquisitor/Inquisitor.bundle/Contents/MacOS/Inquisitor
  0xcbd000 -   0xd16fff com.apple.driver.AppleIntelGMA950GLDriver 1.4.56 (4.5.6)	/System/Library/Extensions/AppleIntelGMA950GLDriver.bundle/Contents/MacOS/AppleIntelGMA950GLDriver
  0xd1d000 -   0xd39fff GLDriver 	/System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLDriver.bundle/GLDriver
  0xd40000 -   0xd64fff GLRendererFloat 	/System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLRendererFloat.bundle/GLRendererFloat
 0x1d35000 -  0x1e8efff GLEngine 	/System/Library/Frameworks/OpenGL.framework/Resources/GLEngine.bundle/GLEngine
0x8fe00000 - 0x8fe4afff dyld 46.12	/usr/lib/dyld
0x90000000 - 0x90171fff libSystem.B.dylib 	/usr/lib/libSystem.B.dylib
0x901c1000 - 0x901c3fff libmathCommon.A.dylib 	/usr/lib/system/libmathCommon.A.dylib
0x901c5000 - 0x90202fff com.apple.CoreText 1.1.2 (???)	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/CoreText
0x90229000 - 0x902fffff ATS 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
0x9031f000 - 0x90774fff com.apple.CoreGraphics 1.258.77 (???)	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
0x9080b000 - 0x908d3fff com.apple.CoreFoundation 6.4.7 (368.28)	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x90911000 - 0x90911fff com.apple.CoreServices 10.4 (???)	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x90913000 - 0x90a07fff libicucore.A.dylib 	/usr/lib/libicucore.A.dylib
0x90a57000 - 0x90ad6fff libobjc.A.dylib 	/usr/lib/libobjc.A.dylib
0x90aff000 - 0x90b63fff libstdc++.6.dylib 	/usr/lib/libstdc++.6.dylib
0x90bd2000 - 0x90bd9fff libgcc_s.1.dylib 	/usr/lib/libgcc_s.1.dylib
0x90bde000 - 0x90c51fff com.apple.framework.IOKit 1.4.8 (???)	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x90c66000 - 0x90c78fff libauto.dylib 	/usr/lib/libauto.dylib
0x90c7e000 - 0x90f24fff com.apple.CoreServices.CarbonCore 682.26	/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
0x90f67000 - 0x90fcffff com.apple.CoreServices.OSServices 4.1	/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
0x91008000 - 0x91047fff com.apple.CFNetwork 129.21	/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
0x9105a000 - 0x9106afff com.apple.WebServices 1.1.3 (1.1.0)	/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/WebServicesCore.framework/Versions/A/WebServicesCore
0x91075000 - 0x910f4fff com.apple.SearchKit 1.0.5	/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
0x9112e000 - 0x9114cfff com.apple.Metadata 10.4.4 (121.36)	/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
0x91158000 - 0x91166fff libz.1.dylib 	/usr/lib/libz.1.dylib
0x91169000 - 0x91308fff com.apple.security 4.5.2 (29774)	/System/Library/Frameworks/Security.framework/Versions/A/Security
0x91406000 - 0x9140efff com.apple.DiskArbitration 2.1.1	/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
0x91415000 - 0x9141cfff libbsm.dylib 	/usr/lib/libbsm.dylib
0x91420000 - 0x91446fff com.apple.SystemConfiguration 1.8.6	/System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
0x91458000 - 0x914cefff com.apple.audio.CoreAudio 3.0.4	/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x9151f000 - 0x9151ffff com.apple.ApplicationServices 10.4 (???)	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
0x91521000 - 0x9154dfff com.apple.AE 314 (313)	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
0x91560000 - 0x91634fff com.apple.ColorSync 4.4.9	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
0x9166f000 - 0x916e2fff com.apple.print.framework.PrintCore 4.6 (177.13)	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
0x91710000 - 0x917b9fff com.apple.QD 3.10.24 (???)	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
0x917df000 - 0x9182afff com.apple.HIServices 1.5.2 (???)	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
0x91849000 - 0x9185ffff com.apple.LangAnalysis 1.6.3	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
0x9186b000 - 0x91886fff com.apple.FindByContent 1.5	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/FindByContent.framework/Versions/A/FindByContent
0x91891000 - 0x918cefff com.apple.LaunchServices 182	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
0x918e2000 - 0x918eefff com.apple.speech.synthesis.framework 3.5	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
0x918f5000 - 0x91935fff com.apple.ImageIO.framework 1.5.5	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
0x91948000 - 0x919fafff libcrypto.0.9.7.dylib 	/usr/lib/libcrypto.0.9.7.dylib
0x91a40000 - 0x91a56fff libcups.2.dylib 	/usr/lib/libcups.2.dylib
0x91a5b000 - 0x91a79fff libJPEG.dylib 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
0x91a7e000 - 0x91addfff libJP2.dylib 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
0x91aef000 - 0x91af3fff libGIF.dylib 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
0x91af5000 - 0x91b7bfff libRaw.dylib 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRaw.dylib
0x91b7f000 - 0x91bbcfff libTIFF.dylib 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
0x91bc2000 - 0x91bdcfff libPng.dylib 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
0x91be1000 - 0x91be3fff libRadiance.dylib 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
0x91be5000 - 0x91cc3fff libxml2.2.dylib 	/usr/lib/libxml2.2.dylib
0x91ce0000 - 0x91ce0fff com.apple.Accelerate 1.3.1 (Accelerate 1.3.1)	/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
0x91ce2000 - 0x91d70fff com.apple.vImage 2.5	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
0x91d77000 - 0x91d77fff com.apple.Accelerate.vecLib 3.3.1 (vecLib 3.3.1)	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
0x91d79000 - 0x91dd2fff libvMisc.dylib 	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
0x91ddb000 - 0x91dfffff libvDSP.dylib 	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
0x91e07000 - 0x92210fff libBLAS.dylib 	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
0x9224a000 - 0x925fefff libLAPACK.dylib 	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
0x9262b000 - 0x92718fff libiconv.2.dylib 	/usr/lib/libiconv.2.dylib
0x9271a000 - 0x92797fff com.apple.DesktopServices 1.3.6	/System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
0x927d8000 - 0x92a08fff com.apple.Foundation 6.4.8 (567.29)	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x92b22000 - 0x92b39fff libGL.dylib 	/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
0x92b44000 - 0x92b9cfff libGLU.dylib 	/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
0x92bb0000 - 0x92bb0fff com.apple.Carbon 10.4 (???)	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
0x92bb2000 - 0x92bc2fff com.apple.ImageCapture 3.0.4	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
0x92bd1000 - 0x92bd9fff com.apple.speech.recognition.framework 3.6	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
0x92bdf000 - 0x92be5fff com.apple.securityhi 2.0.1 (24742)	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
0x92beb000 - 0x92c7cfff com.apple.ink.framework 101.2.1 (71)	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
0x92c90000 - 0x92c94fff com.apple.help 1.0.3 (32.1)	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
0x92c97000 - 0x92cb5fff com.apple.openscripting 1.2.5 (???)	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
0x92cc7000 - 0x92ccdfff com.apple.print.framework.Print 5.2 (192.4)	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
0x92cd3000 - 0x92d36fff com.apple.htmlrendering 66.1 (1.1.3)	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering
0x92d5d000 - 0x92d9efff com.apple.NavigationServices 3.4.4 (3.4.3)	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/NavigationServices.framework/Versions/A/NavigationServices
0x92dc5000 - 0x92dd3fff com.apple.audio.SoundManager 3.9.1	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CarbonSound.framework/Versions/A/CarbonSound
0x92dda000 - 0x92ddffff com.apple.CommonPanels 1.2.3 (73)	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
0x92de4000 - 0x930d9fff com.apple.HIToolbox 1.4.9 (???)	/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
0x931df000 - 0x931eafff com.apple.opengl 1.4.16	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
0x9327a000 - 0x9327afff com.apple.Cocoa 6.4 (???)	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
0x9327c000 - 0x93932fff com.apple.AppKit 6.4.9 (824.44)	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
0x93cb3000 - 0x93d2efff com.apple.CoreData 91 (92.1)	/System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
0x93d67000 - 0x93e21fff com.apple.audio.toolbox.AudioToolbox 1.4.5	/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
0x93e64000 - 0x93e64fff com.apple.audio.units.AudioUnit 1.4.2	/System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
0x93e66000 - 0x94027fff com.apple.QuartzCore 1.4.12	/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
0x9406d000 - 0x940aefff libsqlite3.0.dylib 	/usr/lib/libsqlite3.0.dylib
0x940b6000 - 0x940f0fff libGLImage.dylib 	/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
0x940f5000 - 0x9410bfff com.apple.CoreVideo 1.4.1	/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
0x9429e000 - 0x942adfff libCGATS.A.dylib 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCGATS.A.dylib
0x942b4000 - 0x942bffff libCSync.A.dylib 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCSync.A.dylib
0x9430b000 - 0x94325fff libRIP.A.dylib 	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libRIP.A.dylib
0x97484000 - 0x9755bfff libGLProgrammability.dylib 	/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLProgrammability.dylib
0x97576000 - 0x97577fff libGLSystem.dylib 	/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLSystem.dylib
0xc0000000 - 0xc0008fff com.growl.growlframework 0.7.6	/Applications/HandBrake.app/Contents/Frameworks/Growl.framework/Versions/A/Growl

Model: MacBook2,1, BootROM MB21.00A5.B00, 2 processors, Intel Core 2 Duo, 2 GHz, 3 GB
Graphics: Intel GMA 950, GMA 950, Built-In, spdisplays_integrated_vram
Memory Module: BANK 0/DIMM0, 2 GB, DDR2 SDRAM, 667 MHz
Memory Module: BANK 1/DIMM1, 1 GB, DDR2 SDRAM, 667 MHz
AirPort: AirPort Extreme, 1.1.9.3
Bluetooth: Version 1.9.0f8, 2 service, 1 devices, 1 incoming serial ports
Network Service: AirPort, AirPort, en1
Network Service: Built-in Ethernet, Ethernet, en0
Network Service: Parallels Host-Guest, Ethernet, en2
Network Service: Parallels NAT, Ethernet, en3
Serial ATA Device: TOSHIBA MK1234GSX, 111.79 GB
Parallel ATA Device: [Censored]-R   UJ-857D
USB Device: Built-in iSight, Micron, Up to 480 Mb/sec, 500 mA
USB Device: Apple Internal Keyboard / Trackpad, Apple Computer, Up to 12 Mb/sec, 500 mA
USB Device: IR Receiver, Apple Computer, Inc., Up to 12 Mb/sec, 500 mA
USB Device: Bluetooth USB Host Controller, Apple, Inc., Up to 12 Mb/sec, 500 mA
tweder
Posts: 3
Joined: Tue Sep 18, 2007 10:37 pm

Post by tweder »

verbose CLI output

Code: Select all

scott-twedes-macbook:/Volumes/HandBrake scott$ ./HandBrakeCLI -v -i ~/Desktop/who/E2501 -o ~/Movies/movie.mp4 -t 4 -B 160 -R 48 -E AAC -e x264 -f MP4 -m -p -d -b 2500 -x bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2:cabac=0 
[20:12:21] hb_init: checking cpu count
[20:12:21] hb_init: starting libhb thread
[20:12:21] thread 2004200 started ("libhb")
HandBrake 0.9.0 (2007081900) - http://handbrake.m0k.org/
2 CPUs detected
Opening /Users/scott/Desktop/who/E2501...
[20:12:21] hb_scan: path=/Users/scott/Desktop/who/E2501, title_index=4
[20:12:21] thread 2004600 started ("scan")
[20:12:21] scan: trying to open with libdvdread
[20:12:22] scan: DVD has 8 title(s)
[20:12:22] scan: scanning title 4
[20:12:22] scan: opening IFO for VTS 3
[20:12:22] scan: vts=3, ttn=2, cells=0->14, blocks=0->3315422, 1107736 blocks
[20:12:22] scan: duration is 00:45:03 (2703210 ms)
[20:12:22] scan: checking audio 1
[20:12:22] scan: id=80bd, lang=English (AC3), 3cc=eng
[20:12:22] scan: checking audio 2
[20:12:22] scan: id=81bd, lang=English (AC3), 3cc=eng
[20:12:22] scan: checking subtitle 1
[20:12:22] scan: id=20bd, lang=English, 3cc=eng
[20:12:22] scan: title 4 has 15 chapters
[20:12:22] scan: chapter 15 too short (4 blocks, cells=14->14), merging
[20:12:22] scan: chap 1 c=0->0, b=0->15670 (15671), 38256 ms
[20:12:22] scan: chap 2 c=1->1, b=15671->118882 (103212), 250612 ms
[20:12:22] scan: chap 3 c=2->2, b=118883->204522 (85640), 208738 ms
[20:12:22] scan: chap 4 c=3->3, b=204523->303437 (98915), 248808 ms
[20:12:22] scan: chap 5 c=4->4, b=303438->380359 (76922), 186678 ms
[20:12:22] scan: chap 6 c=5->5, b=380360->473617 (93258), 226528 ms
[20:12:22] scan: chap 7 c=6->6, b=473618->569834 (96217), 233777 ms
[20:12:22] scan: chap 8 c=7->7, b=569835->720968 (151134), 367872 ms
[20:12:22] scan: chap 9 c=8->8, b=720969->802505 (81537), 198550 ms
[20:12:22] scan: chap 10 c=9->9, b=802506->895874 (93369), 226596 ms
[20:12:22] scan: chap 11 c=10->10, b=895875->987217 (91343), 222653 ms
[20:12:22] scan: chap 12 c=11->11, b=987218->1073321 (86104), 209473 ms
[20:12:22] scan: chap 13 c=12->12, b=1073322->1089334 (16013), 38366 ms
[20:12:22] scan: chap 14 c=13->14, b=1089335->3315422 (18401), 46297 ms
[20:12:22] scan: aspect = 16
[20:12:22] scan: decoding previews for title 4
[20:12:22] scan: preview 1
[20:12:22] scan: AC3, rate=48000Hz, bitrate=448000
[20:12:22] scan: AC3, rate=48000Hz, bitrate=192000
[20:12:22] scan: preview 2
[20:12:22] scan: preview 3
[20:12:22] scan: preview 4
[20:12:22] scan: preview 5
[20:12:22] scan: preview 6
[20:12:22] scan: preview 7
[20:12:22] scan: preview 8
[20:12:22] scan: preview 9
[20:12:22] scan: preview 10
[20:12:22] scan: 720x480, 29.970 fps, autocrop = 0/0/0/0
[20:12:22] scan: title (0) job->width:720, job->height:400
[20:12:22] thread 2004600 exited ("scan")
[20:12:22] thread 2004600 joined ("scan")
[20:12:22] libhb: scan thread found 1 valid title(s)
+ title 4:
  + vts 3, ttn 2, cells 0->14 (1107736 blocks)
  + duration: 00:45:03
  + size: 720x480, aspect: 1.78, 29.970 fps
  + autocrop: 0/0/0/0
  + chapters:
    + 1: cells 0->0, 15671 blocks, duration 00:00:38
    + 2: cells 1->1, 103212 blocks, duration 00:04:11
    + 3: cells 2->2, 85640 blocks, duration 00:03:29
    + 4: cells 3->3, 98915 blocks, duration 00:04:09
    + 5: cells 4->4, 76922 blocks, duration 00:03:07
    + 6: cells 5->5, 93258 blocks, duration 00:03:47
    + 7: cells 6->6, 96217 blocks, duration 00:03:54
    + 8: cells 7->7, 151134 blocks, duration 00:06:08
    + 9: cells 8->8, 81537 blocks, duration 00:03:19
    + 10: cells 9->9, 93369 blocks, duration 00:03:47
    + 11: cells 10->10, 91343 blocks, duration 00:03:43
    + 12: cells 11->11, 86104 blocks, duration 00:03:29
    + 13: cells 12->12, 16013 blocks, duration 00:00:38
    + 14: cells 13->14, 18401 blocks, duration 00:00:46
  + audio tracks:
    + 1, English (AC3) (5.1 ch), 48000Hz, 448000bps
    + 2, English (AC3) (2.0 ch), 48000Hz, 192000bps
  + subtitle tracks:
    + 1, English (iso639-2: eng)
Applying the following x264 options: bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2:cabac=0
[20:12:22] thread 2004600 started ("work")
[20:12:22] 1 job(s) to process
[20:12:22] starting job
[20:12:22]  + device /Users/scott/Desktop/who/E2501
[20:12:22]  + title 4, chapter(s) 1 to 14
[20:12:22]  + 720x480 -> 720x480, crop 0/0/0/0
[20:12:22]  + grayscale off
[20:12:22]  + filters
[20:12:22]    + Deinterlace (ffmpeg or yadif/mcdeint) (default settings)
[20:12:22]  + 29.970 fps, video bitrate 2500 kbps, pass 0
[20:12:22]  + PixelRatio: 1, width:720, height: 480
[20:12:22]  + encoder x264
[20:12:22]  + audio 160 kbps, 48000 Hz
[20:12:22]  + encoder faac
[20:12:22]    + 80bd, English (AC3) (5.1 ch)
[20:12:22]      + Requested mixdown: Dolby Pro Logic II (HB_AMIXDOWN_DOLBYPLII)
[20:12:22]      + Actual mixdown: Dolby Pro Logic II (HB_AMIXDOWN_DOLBYPLII)
[20:12:22] thread 2007a00 started ("reader")
[20:12:22]  + output: /Users/scott/Movies/movie.mp4
[20:12:22] thread 2007e00 started ("muxer")
[20:12:22] thread 2008200 started ("MPEG-2 decoder (libmpeg2)")
[20:12:22] thread 2008a00 started ("Renderer")
[20:12:22] encx264: encoding with stored aspect 32/27
[20:12:22] encx264: opening libx264 (pass 0)
x264 [info]: using SAR=32/27
x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 
[20:12:22] thread 2043800 started ("H.264/AVC encoder (libx264)")
No accelerated IMDCT transform found
[20:12:22] thread 2010000 started ("AC3 decoder")
[20:12:22] thread 202ba00 started ("AAC encoder (libfaac)")
[20:12:22] sync: expecting 81045 video frames
[20:12:22] DVD: Beginning of Cell
[20:12:22] sync: first pts is 25257
Encoding: task 1 of 1, 1.13 % (24.60 fps, avg 24.03 fps, ETA 00h55m35s)[20:13:00] DVD: End of Cell
Encoding: task 1 of 1, 1.16 % (24.63 fps, avg 24.05 fps, ETA 00h55m31s)[20:13:01] DVD: Beginning of Cell
[20:13:01] DVD: Chapter Break Cell Found
Encoding: task 1 of 1, 1.40 % (20.36 fps, avg 23.58 fps, ETA 00h56m29s)MPEG2: Chapter Break Cell Found, searching for GOP
MPEG2: Group of pictures found, searching for I-Frame
Encoding: task 1 of 1, 1.41 % (20.36 fps, avg 23.58 fps, ETA 00h56m29s)MPEG2: I-Frame Found
MPEG2: Chapter Break Inserted
Encoding: task 1 of 1, 1.43 % (20.36 fps, avg 23.58 fps, ETA 00h56m29s)WORK: Copying Chapter Break
Encoding: task 1 of 1, 1.44 % (22.76 fps, avg 23.66 fps, ETA 00h56m16s)WORK: Copying Chapter Break
Encoding: task 1 of 1, 10.44 % (20.92 fps, avg 20.84 fps, ETA 00h58m02s)[20:19:08] DVD: End of Cell
Encoding: task 1 of 1, 10.48 % (21.64 fps, avg 20.85 fps, ETA 00h58m00s)[20:19:09] DVD: Beginning of Cell
[20:19:09] DVD: Chapter Break Cell Found
Encoding: task 1 of 1, 10.69 % (17.07 fps, avg 20.84 fps, ETA 00h57m54s)MPEG2: Chapter Break Cell Found, searching for GOP
MPEG2: Group of pictures found, searching for I-Frame
MPEG2: I-Frame Found
MPEG2: Chapter Break Inserted
Encoding: task 1 of 1, 10.71 % (17.67 fps, avg 20.83 fps, ETA 00h57m54s)WORK: Copying Chapter Break
Encoding: task 1 of 1, 10.72 % (17.67 fps, avg 20.83 fps, ETA 00h57m54s)WORK: Copying Chapter Break
Encoding: task 1 of 1, 18.18 % (19.83 fps, avg 20.27 fps, ETA 00h54m31s)[20:24:29] DVD: End of Cell
Encoding: task 1 of 1, 18.19 % (19.83 fps, avg 20.27 fps, ETA 00h54m31s)[20:24:29] DVD: Beginning of Cell
[20:24:29] DVD: Chapter Break Cell Found
Encoding: task 1 of 1, 18.40 % (21.25 fps, avg 20.26 fps, ETA 00h54m25s)MPEG2: Chapter Break Cell Found, searching for GOP
MPEG2: Group of pictures found, searching for I-Frame
MPEG2: I-Frame Found
MPEG2: Chapter Break Inserted
Encoding: task 1 of 1, 18.41 % (22.48 fps, avg 20.26 fps, ETA 00h54m24s)Segmentation fault
eddyg
Veteran User
Posts: 798
Joined: Mon Apr 23, 2007 3:34 am

Post by eddyg »

I've looked at the code, and it appears that any crash at that point is
due to the MPEG decoder not providing us with valid data, and so we
read garbage.

The crash was here:

Code: Select all

Thread 8 Crashed: 
0   <<00000000>>    0xffff0884 __memcpy + 228 (cpu_capabilities.h:228) 
1   org.m0k.handbrake                 0x00021b63 hb_libmpeg2_decode + 594 (decmpeg2.c:167) 
2   org.m0k.handbrake                 0x00021ed4 decmpeg2Work + 102 (decmpeg2.c:388) 
3   org.m0k.handbrake                 0x00033127 work_loop + 96 (work.c:667) 
4   org.m0k.handbrake                 0x0002a6e8 hb_thread_func + 73 (ports.c:270) 
5   libSystem.B.dylib                 0x90024227 _pthread_body + 84 
Which is the following block of code:

Code: Select all

                buf  = hb_buffer_init( m->width * m->height * 3 / 2 );
                data = buf->data;

                // Was a good break point found?
                if( chap_break )
                {
                    hb_log("MPEG2: Chapter Break Inserted");
                    chap_break = 0;
                    buf->new_chap = 1;
                }

                memcpy( data, m->info->display_fbuf->buf[0],
                        m->width * m->height );
                data += m->width * m->height;
                memcpy( data, m->info->display_fbuf->buf[1],
                        m->width * m->height / 4 );
                data += m->width * m->height / 4;
                memcpy( data, m->info->display_fbuf->buf[2], <<< crash
                        m->width * m->height / 4 );
Therefore I suspect that the MPEG2 decoder provided display_fbuf is not actually valid, and we have not detected the error. We have checked prior to this point whether display_fbuf exists, so maybe buf[0-2] were not allocated?

Or maybe the width/height has changed and we don't know about it, and so copied past where we ought to have.

Maybe we ought to be using m->info->sequence->width and height rather than our stored versions when allocating the buffer and copying into it?

So tweder, there are two things you could try to see if you can fix the bug. I can't do much from here as I don't have that material.

Cheers, Ed.
Jeffe
Posts: 4
Joined: Mon Dec 03, 2007 12:10 am

Post by Jeffe »

For what it's worth, I tried it on in Windows, and it gets all squirrelly at that moment, and stays that way for a little while - dunno what would trigger the picture to get "normal" again, maybe a new chapter break?
Harris
Posts: 11
Joined: Sun Dec 30, 2007 1:27 pm

Post by Harris »

Under Windows (version 0.9.1), this is what squirrely means.

Obviously there's some sort of mismatch in the dimensions or aspect ratio. Unfortunately, I don't understand the innards of Handbrake well enough to begin to guess what exactly is wrong. I have tried explicitly using m->info->sequence->width and height for the memcpy() statements shown above, no effect.

As mentioned before, it produces this result on chapter four of title four of the disc in question, and only that chapter. As soon as it hits chapter five, it goes back to normal. It produces this effect whether encoding just that chapter, or the surrounding chapters along with it, makes no difference.

When I play the DVD in my regular DVD player program, every chapter *except* chapter four has a few pixels of black padding on the sides of the screen. Chapter four has none--it lines up flush with the sides of the screen. I can't find any other differences yet.

I'm going to keep fiddling. Any more ideas where to start?
Harris
Posts: 11
Joined: Sun Dec 30, 2007 1:27 pm

Post by Harris »

Okay, found a fix, but I'm unsure how to code it in elegantly.

That particular chapter on the DVD is stored as 704x480 instead of the regular 720x480. libmpeg2 emits a STATE_SEQUENCE with the new information, but hb_libmpeg2_decode() never checks to see if the dimensions have been altered.

That explains why it looks the way it does when encoded in windows: it's putting 704 pixels of data into a space for 720, but I don't really know why it would segfault on a Mac. Maybe when it hits chapter 5, and goes back from 704 to 720? At any rate...

What needs to happen is:
1) hb_libmpeg2_decode() checks for new width and height. If there are new values, this thread passes a message to the renderer, telling it to reinitialize its context.
2) The renderer receives the decoder's message and reinitializes its context, if necessary. It must do so at the appropriate time--too early or too late will inject some garbage into the video.

I've written a quick and dirty hack to this effect, and it works almost perfectly. Almost. There is a split-second of garbage at the moment it switches from one width to the next--I assume because the renderer has to lag behind the decoder a little bit, so telling the renderer to reinitialize its context at the exact moment the STATE_SEQUENCE is received is actually a little bit too early for the renderer, and it ends up encoding garbage for a frame or two.

So I have two questions for those of you who know this stuff better than me. First, how would I elegantly pass a message from the mpeg2 thread to the renderer? And second, how would I make sure it is in sync with the buffer?

Or would there be a more suitable point at which to send the message, instead of inside hb_libmpeg2_decode()?
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Post by jbrjake »

Harris wrote:First, how would I elegantly pass a message from the mpeg2 thread to the renderer?
Well the hb_buffer struct already has variables for width and height. Just set them properly in decmpeg2.

I'm not sure, btw, that it's such a great idea to be changing buffer sizes on the fly like that. I'm not positive that libhb can handle that properly....the garbage as it switches might be unavoidable.
Harris
Posts: 11
Joined: Sun Dec 30, 2007 1:27 pm

Post by Harris »

Haha, the solution would be staring me right in the face, wouldn't it? :)

I had the same misgivings about adjusting the buffer size mid-job like that, but the following patches to decmpeg2.c and render.c seem to work fine:

decmpeg2.c.diff:

Code: Select all

98c98,101
<             if( !( m->width && m->height && m->rate ) )
---
>             /* If the stream's dimensions have changed, we need to detect and adjust fire */
>         	if( !( m->width && m->height && m->rate ) ||
>         			m->width != m->info->sequence->width ||
>         			m->height != m->info->sequence->height )
152a156,158
>                 /* Set these so the renderer can monitor changes */
>                 buf->width = m->width;
>                 buf->height = m->height;
render.c.diff:

Code: Select all

148a149,176
> /* Allows easy reinitialization of the context */
> void render_context_init ( hb_work_object_t *w ) {
> 	hb_work_private_t *pv = w->private_data;
> 	hb_job_t *job = pv->job;
> 	hb_title_t *title = job->title;
> 	
> 	/* Uhm... is there anything in pv->context that we need to save? */
> 	if (pv->context) {
> 		free(pv->context);
> 		pv->context = NULL;	/* This line is important. :) */
> 	}
> 	
>     /* If crop or scale is specified, setup rescale context */
>     if( job->crop[0] || job->crop[1] || job->crop[2] || job->crop[3] ||
>         job->width != title->width || job->height != title->height )
>     {
>     	
>     	hb_log("Renderer: Getting context for %dx%d -> %dx%d",
>     			title->width, title->height, job->width, job->height);
> 
>         pv->context = sws_getContext(title->width  - (job->crop[2] + job->crop[3]),
>                                      title->height - (job->crop[0] + job->crop[1]),
>                                      PIX_FMT_YUV420P,
>                                      job->width, job->height, PIX_FMT_YUV420P,
>                                      (uint16_t)(SWS_LANCZOS|SWS_ACCURATE_RND), NULL, NULL, NULL);
>     }
> }
> 
183a212,221
>     /* If new dimensions are detected, we need to initialize, reinitialize or delete the context */
>      if ((in->width || in->height) && 
>      		(in->width != title->width || in->height != title->height)) {
>      	if (in->width)
>      		title->width = in->width;
>      	if (in->height)
>      		title->height = in->height;
>      	render_context_init(w);
>      }
>     
342,351c380,381
<     /* If crop or scale is specified, setup rescale context */
<     if( job->crop[0] || job->crop[1] || job->crop[2] || job->crop[3] ||
<         job->width != title->width || job->height != title->height )
<     {
<         pv->context = sws_getContext(title->width  - (job->crop[2] + job->crop[3]),
<                                      title->height - (job->crop[0] + job->crop[1]),
<                                      PIX_FMT_YUV420P,
<                                      job->width, job->height, PIX_FMT_YUV420P,
<                                      (uint16_t)(SWS_LANCZOS|SWS_ACCURATE_RND), NULL, NULL, NULL);
<     }   
---
>     /* Moved this to its own function so it can be reinitialized at will */
>     render_context_init(w); 
The DVD in question now encodes without a glitch (no hiccups or garbage of any kind at the chapter switches). I've tried it with the iPod hi-rez preset and a very quick and ugly anamorphic PAR encode, both with the same positive result. My high quality anamorphic PAR is still chugging along.

The only couple issues I have left are: Is it safe to be fiddling with title->width and title->height from within render.c? It doesn't really feel right, but seemed the simplest thing to do. And anamorphic PAR--it works with this DVD by stretching the 704x480 chapter out to 720x480, but that means that by the time the video gets to anyone's eyeballs, it will have been stretched not once, but twice, which seems neither polite nor very optimal.
Jeffe
Posts: 4
Joined: Mon Dec 03, 2007 12:10 am

Post by Jeffe »

Harris wrote:Under Windows (version 0.9.1), this is what squirrely means.
Well, perhaps it's not a very descriptive word in this case, but then it does kind of go with the theme of Sylvester McCoy being known for putting ferrets down his pants! :D

Erm, anyway, thrilled to hear there's a solution brewing, thanks everyone!
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Post by jbrjake »

Nice, Harris! As you can tell from the length and age of this thread, it's quite an old and enduring bug you've squashed here.
Harris wrote:The only couple issues I have left are: Is it safe to be fiddling with title->width and title->height from within render.c? It doesn't really feel right, but seemed the simplest thing to do.
Right...I have the same worries.
And anamorphic PAR--it works with this DVD by stretching the 704x480 chapter out to 720x480, but that means that by the time the video gets to anyone's eyeballs, it will have been stretched not once, but twice, which seems neither polite nor very optimal.
Hmmmm....I'm not sure there's an easy way around this. I think x264 might need a new slice every time dimensions change? And I've never really played around enough with variable dimensions to see how it's signalled. Maybe start by changing the job->width and ->height as well, when you change the sequence. That should get them scaled to the right frame size for anamorphic, at least. Except for the cropping....would probably need to run autocrop every time the sequence dims change. And that code's bound into scanning right now, might not be easy to extract it.
Harris
Posts: 11
Joined: Sun Dec 30, 2007 1:27 pm

Post by Harris »

Here are updated versions of those diff files. The only two changes are that it uses sws_freeContext() instead of free() when reinitializing a context, and it uses private_data struct variables pv->width and pv->height in place of the title struct dimension variables. This is safer, but a bit sucky because I had to rename every instance of title->width and title->height to pv->width and pv->height to get it to work properly. If this is acceptable, please commit! :)

Edit: I should have pointed out, these patches are based on the 0.9.1 source.

decmpeg2.c.diff:

Code: Select all

98c98,101
<             if( !( m->width && m->height && m->rate ) )
---
>             /* If the stream's dimensions have changed, we need to detect and adjust fire */
>         	if( !( m->width && m->height && m->rate ) ||
>         			m->width != m->info->sequence->width ||
>         			m->height != m->info->sequence->height )
152a156,158
>                 /* Set these so the renderer can monitor changes */
>                 buf->width = m->width;
>                 buf->height = m->height;
render.c.diff:

Code: Select all

21a22,24
> 
>     int			 width;
>     int			 height;
57c60
< static void ApplySub( hb_job_t * job, hb_buffer_t * buf,
---
> static void ApplySub( hb_work_object_t * w, hb_buffer_t * buf,
59a63,64
>     hb_work_private_t * pv = w->private_data;
>     hb_job_t * job = pv->job;
74,75c79,80
<     if( sub->height > title->height - job->crop[0] - job->crop[1] - 40 )
<         offset_top = job->crop[0] + ( title->height - job->crop[0] -
---
>     if( sub->height > pv->height - job->crop[0] - job->crop[1] - 40 )
>         offset_top = job->crop[0] + ( pv->height - job->crop[0] -
79,80c84,85
<     else if( sub->y > title->height - job->crop[1] - 20 - sub->height )
<         offset_top = title->height - job->crop[1] - 20 - sub->height;
---
>     else if( sub->y > pv->height - job->crop[1] - 20 - sub->height )
>         offset_top = pv->height - job->crop[1] - 20 - sub->height;
84,85c89,90
<     if( sub->width > title->width - job->crop[2] - job->crop[3] - 40 )
<         offset_left = job->crop[2] + ( title->width - job->crop[2] -
---
>     if( sub->width > pv->width - job->crop[2] - job->crop[3] - 40 )
>         offset_left = job->crop[2] + ( pv->width - job->crop[2] -
89,90c94,95
<     else if( sub->x > title->width - job->crop[3] - 20 - sub->width )
<         offset_left = title->width - job->crop[3] - 20 - sub->width;
---
>     else if( sub->x > pv->width - job->crop[3] - 20 - sub->width )
>         offset_left = pv->width - job->crop[3] - 20 - sub->width;
99c104
<     out   = buf->data + offset_top * title->width + offset_left;
---
>     out   = buf->data + offset_top * pv->width + offset_left;
103c108
<         if( offset_top + i >= 0 && offset_top + i < title->height )
---
>         if( offset_top + i >= 0 && offset_top + i < pv->height )
107c112
<                 if( offset_left + j >= 0 && offset_left + j < title->width )
---
>                 if( offset_left + j >= 0 && offset_left + j < pv->width )
120c125
<                     chromaU = getU(buf->data, title->width, title->height,
---
>                     chromaU = getU(buf->data, pv->width, pv->height,
123c128
<                     chromaV = getV(buf->data, title->width, title->height,
---
>                     chromaV = getV(buf->data, pv->width, pv->height,
143c148
<         out   += title->width;
---
>         out   += pv->width;
148a154,180
> /* Allows easy reinitialization of the context */
> void render_context_init ( hb_work_object_t *w ) {
> 	hb_work_private_t *pv = w->private_data;
> 	hb_job_t *job = pv->job;
> 
> 	/* Uhm... is there anything in pv->context that we need to save? */
> 	if (pv->context) {
> 		sws_freeContext(pv->context);
> 		pv->context = NULL;	/* This line is important. :) */
> 	}
> 	
>     /* If crop or scale is specified, setup rescale context */
>     if( job->crop[0] || job->crop[1] || job->crop[2] || job->crop[3] ||
>         job->width != pv->width || job->height != pv->height )
>     {
>     	
>     	hb_log("Renderer: Getting context for %dx%d -> %dx%d",
>     			pv->width, pv->height, job->width, job->height);
> 
>         pv->context = sws_getContext(pv->width  - (job->crop[2] + job->crop[3]),
>                                      pv->height - (job->crop[0] + job->crop[1]),
>                                      PIX_FMT_YUV420P,
>                                      job->width, job->height, PIX_FMT_YUV420P,
>                                      (uint16_t)(SWS_LANCZOS|SWS_ACCURATE_RND), NULL, NULL, NULL);
>     }
> }
> 
155a188,197
>       
>     /* If new dimensions are detected, we need to initialize, reinitialize or delete the context */
>     if ((in->width || in->height) && 
>      		(in->width != pv->width || in->height != pv->height)) {
> 	if (in->width)
>      		pv->width = in->width;
>      	if (in->height)
>      		pv->height = in->height;
>      	render_context_init(w);
>     }
207,208c249,250
<                                        title->width, 
<                                        title->height, 
---
>                                        pv->width, 
>                                        pv->height, 
241c283
<             ApplySub( job, buf_tmp_in, &subtitles );
---
>             ApplySub( w, buf_tmp_in, &subtitles );
250c292
<                         title->width, title->height );
---
>                         pv->width, pv->height );
263c305
<                   0, title->height - (job->crop[0] + job->crop[1]),
---
>                   0, pv->height - (job->crop[0] + job->crop[1]),
340a383,385
>     
>     pv->width = title->width;
>     pv->height = title->height;
342,351c387,388
<     /* If crop or scale is specified, setup rescale context */
<     if( job->crop[0] || job->crop[1] || job->crop[2] || job->crop[3] ||
<         job->width != title->width || job->height != title->height )
<     {
<         pv->context = sws_getContext(title->width  - (job->crop[2] + job->crop[3]),
<                                      title->height - (job->crop[0] + job->crop[1]),
<                                      PIX_FMT_YUV420P,
<                                      job->width, job->height, PIX_FMT_YUV420P,
<                                      (uint16_t)(SWS_LANCZOS|SWS_ACCURATE_RND), NULL, NULL, NULL);
<     }   
---
>     /* Moved this to its own function so it can be reinitialized at will */
>     render_context_init(w); 
370,371c407,408
<                                                  title->width,
<                                                  title->height,
---
>                                                  pv->width,
>                                                  pv->height,
Post Reply