Skip to content

Commit

Permalink
Use a buffer to read picture data [#266]
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeugma440 committed May 20, 2024
1 parent ba9863c commit a000838
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ATL/AudioData/IO/ID3v2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ Frame size encoding conventions
chapter.StartOffset = StreamUtils.DecodeBEUInt32(source.ReadBytes(4));
chapter.EndOffset = StreamUtils.DecodeBEUInt32(source.ReadBytes(4));

chapter.UseOffset = (chapter.StartOffset != uint.MaxValue);
chapter.UseOffset = chapter.StartOffset != uint.MaxValue;

long remainingData = dataSize - (source.Position - initPos);
while (remainingData > 0)
Expand Down
1 change: 0 additions & 1 deletion ATL/AudioData/IO/WMA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Collections.Concurrent;
using static ATL.TagData;
using System.Threading.Tasks;
using System.Reflection;

namespace ATL.AudioData.IO
{
Expand Down
14 changes: 7 additions & 7 deletions ATL/Entities/PictureInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,20 @@ public static PictureInfo fromBinaryData(byte[] data, PIC_TYPE picType = PIC_TYP
/// <summary>
/// Construct picture information from its raw, binary data
/// </summary>
/// <param name="stream">Stream containing raw picture data, positioned at the beginning of picture data</param>
/// <param name="length">Length of the picture data to read inside the given stream</param>
/// <param name="inStream">Stream containing raw picture data, positioned at the beginning of picture data</param>
/// <param name="length">Length of the picture data to read inside the given Stream</param>
/// <param name="picType">Type of the picture (default : Generic)</param>
/// <param name="tagType">Type of the containing tag (default : TAG_ANY)</param>
/// <param name="nativePicCode">Native code of the picture, as stated in its containing format's specs (default : not set)</param>
/// <param name="position">Position of the picture among the other pictures of the same file (default : 1)</param>
/// <returns></returns>
public static PictureInfo fromBinaryData(Stream stream, int length, PIC_TYPE picType, TagType tagType, object nativePicCode, int position = 1)
public static PictureInfo fromBinaryData(Stream inStream, int length, PIC_TYPE picType, TagType tagType, object nativePicCode, int position = 1)
{
if (null == stream) throw new ArgumentException("Stream should not be null");
if (null == inStream) throw new ArgumentException("Stream should not be null");

byte[] data = new byte[length];
stream.Read(data, 0, length);
return new PictureInfo(picType, tagType, nativePicCode, position, data);
using MemoryStream outStream = new MemoryStream(length);
StreamUtils.CopyStream(inStream, outStream, length);
return new PictureInfo(picType, tagType, nativePicCode, position, outStream.ToArray());
}

// ---------------- CONSTRUCTORS
Expand Down

0 comments on commit a000838

Please sign in to comment.