<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>I have some (maybe corrupt) mp4 tracks that have an cover. The cover part contains a 'data' atom and afterwards a 'name' atom. This has the effect that the following method returns without adding a cover.</div><div><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">MP4::<span style="color: #558186">Tag</span>::parseCovr(MP4::Atom *atom, <span style="color: #558186">TagLib</span>::<span style="color: #558186">File</span> *<span style="color: #558186">file</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> MP4::CoverArtList <span style="color: #558186">value</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(85, 129, 134); "><span style="color: #000000"> </span>ByteVector<span style="color: #000000"> </span>data<span style="color: #000000"> = </span>file<span style="color: #000000">-></span><span style="color: #36595d">readBlock</span><span style="color: #000000">(atom-></span>length<span style="color: #000000"> - </span><span style="color: #3800d5">8</span><span style="color: #000000">);</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(181, 19, 161); "><span style="color: #000000"> </span>unsigned<span style="color: #000000"> </span>int<span style="color: #000000"> </span><span style="color: #558186">pos</span><span style="color: #000000"> = </span><span style="color: #3800d5">0</span><span style="color: #000000">;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #b513a1">while</span>(<span style="color: #558186">pos</span> < <span style="color: #558186">data</span>.<span style="color: #36595d">size</span>()) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #b513a1">int</span> <span style="color: #558186">length</span> = <span style="color: #558186">data</span>.<span style="color: #36595d">mid</span>(<span style="color: #558186">pos</span>, <span style="color: #3800d5">4</span>).<span style="color: #36595d">toUInt</span>();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #558186">ByteVector</span> name = <span style="color: #558186">data</span>.<span style="color: #36595d">mid</span>(<span style="color: #558186">pos</span> + <span style="color: #3800d5">4</span>, <span style="color: #3800d5">4</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #b513a1">int</span> <span style="color: #558186">flags</span> = <span style="color: #558186">data</span>.<span style="color: #36595d">mid</span>(<span style="color: #558186">pos</span> + <span style="color: #3800d5">8</span>, <span style="color: #3800d5">4</span>).<span style="color: #36595d">toUInt</span>();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #b513a1">if</span>(name != <span style="color: #c92925">"data"</span>) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(201, 41, 37); "><span style="color: #000000"> </span><span style="color: #36595d">debug</span><span style="color: #000000">(</span>"MP4: Unexpected atom \""<span style="color: #000000"> + name + </span>"\", expecting \"data\""<span style="color: #000000">);</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #b513a1">return</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #b513a1">if</span>(<span style="color: #558186">flags</span> == MP4::CoverArt::PNG || <span style="color: #558186">flags</span> == MP4::CoverArt::JPEG) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #558186">value</span>.<span style="color: #36595d">append</span>(MP4::CoverArt(MP4::CoverArt::Format(<span style="color: #558186">flags</span>),</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #558186">data</span>.<span style="color: #36595d">mid</span>(<span style="color: #558186">pos</span> + <span style="color: #3800d5">16</span>, <span style="color: #558186">length</span> - <span style="color: #3800d5">16</span>)));</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #558186">pos</span> += <span style="color: #558186">length</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #b513a1">if</span>(<span style="color: #558186">value</span>.<span style="color: #36595d">size</span>() > <span style="color: #3800d5">0</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #558186">d</span>->items.<span style="color: #36595d">insert</span>(atom-><span style="color: #558186">name</span>, <span style="color: #558186">value</span>);</div><div><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">}</span></div><div><br></div><div><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "></span> <br><div><div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="font-size: 12px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">So the <span class="Apple-style-span" style="font-size: 11px; color: rgb(181, 19, 161); font-family: Menlo; ">return</span> in the <span class="Apple-style-span" style="font-size: 11px; color: rgb(181, 19, 161); font-family: Menlo; ">i<span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; "><span class="Apple-style-span" style="font-size: 11px; font-family: Menlo; "><span style="color: rgb(181, 19, 161); ">f</span>(name != <span style="color: rgb(201, 41, 37); ">"data"</span>)... </span>should be a <span class="Apple-style-span" style="font-size: 11px; color: rgb(181, 19, 161); font-family: Menlo; ">break<span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; "> right? That would ignore the unexpected atom but still adds the maybe previously correct parsed 'data' atom to <span class="Apple-style-span" style="font-size: 11px; font-family: Menlo; "><span style="color: rgb(85, 129, 134); ">d</span>->items</span>. Because (at least) iTunes can read the covers from these tracks.</span></span></span></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="font-size: 11px; color: rgb(181, 19, 161); font-family: Menlo; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; "><span class="Apple-style-span" style="font-size: 11px; color: rgb(181, 19, 161); font-family: Menlo; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; "> </span></span></span></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Thomas Post</div><div>-----------------------------------------------------------------------------------------------------------</div><div><br></div><div>equinux Aktiengesellschaft</div><div>Informationstechnologien</div><div>Kirschstraße 35</div><div>80999 München - Germany</div><div>Tel. +49-89-520465-339</div><div>Fax +49-89-520465-299</div><div><a href="mailto:post@equinux.de">mailto:post@equinux.de</a></div><div><a href="http://www.equinux.com/de">http://www.equinux.com/de</a></div><div>-----------------------------------------------------------------------------------------------------------</div><div>Vorstand: Till Schadde - Aufsichtsrat: Stefan Neuenhahn</div><div>USt-IdNr.: DE206360115 - Sitz München - HRB München 129700</div><div>-----------------------------------------------------------------------------------------------------------</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">equinux USA, Inc.</div><div>100 Produce Ave. Suite L, South San Francisco, CA 94080 </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Toll free: 1-888-equinux (1-888-3784689)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="http://www.equinux.com/">http://www.equinux.com</a></div><div>-----------------------------------------------------------------------------------------------------------</div><div><br class="khtml-block-placeholder"></div></span>Stay updated what's going on at equinux<br><a href="http://blog.equinux.com/">equinux Blog</a> | <a href="http://www.twitter.com/equinux">equinux @ Twitter</a> | <a href="http://www.facebook.com/pages/equinux/43701393352">equinux @ Facebook</a></div></div></span></div></span></div></span></div></span></div>
</div>
<br></div></div></body></html>