From ed29ba8f8bc4727e06ad0dcc730a27887b1ce78a Mon Sep 17 00:00:00 2001
From: Rodrigo Braz Monteiro <zeratul@cellosoft.com>
Date: Mon, 21 Jan 2008 21:25:06 +0000
Subject: [PATCH] .sup generation presumably complete.

Originally committed to SVN as r1810.
---
 aegisub/subtitle_format_dvd.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/aegisub/subtitle_format_dvd.cpp b/aegisub/subtitle_format_dvd.cpp
index 8137dce0b..9130c02cd 100644
--- a/aegisub/subtitle_format_dvd.cpp
+++ b/aegisub/subtitle_format_dvd.cpp
@@ -250,6 +250,7 @@ void DVDSubtitleFormat::GetSubPictureList(std::vector<SubPicture> &pics) {
 
 				// Advance
 				dataRead += (2*w-sw)*3;
+				//dataRead += sw*3;
 			}
 
 			// Encode into subpicture format
@@ -264,6 +265,8 @@ void DVDSubtitleFormat::GetSubPictureList(std::vector<SubPicture> &pics) {
 
 				// End of line, write b000000cc
 				if (groups[m].eol) nibbles = 4;
+
+				// Get proper nibble count
 				else {
 					if (len < 4) nibbles = 1;
 					else if (len < 16) nibbles = 2;
@@ -284,10 +287,14 @@ void DVDSubtitleFormat::GetSubPictureList(std::vector<SubPicture> &pics) {
 					}
 					else data.back() = nibble[n] | last;
 					off = !off;
+
+					// Check if just wrote end of line
+					if (len == 0 && n == 0) {
+						last = 0;
+						off = false;
+					}
 				}
 			}
-			last = 0;
-			off = false;
 			data.resize(data.size());
 		}
 	}
-- 
GitLab