Misc: Remove ape feature

This commit is contained in:
Serial 2023-01-05 00:11:56 -05:00 committed by Alex
parent 75d683a7bf
commit c62981fc81
13 changed files with 20 additions and 90 deletions

View file

@ -30,8 +30,7 @@ once_cell = "1.16.0"
paste = "1.0.11"
[features]
default = ["ape", "id3v2", "aiff_text_chunks", "riff_info_list"]
ape = []
default = ["id3v2", "aiff_text_chunks", "riff_info_list"]
id3v2 = ["flate2"]
id3v2_restrictions = []
aiff_text_chunks = []

View file

@ -1,4 +1,3 @@
#[cfg(feature = "ape")]
pub(super) const INVALID_KEYS: [&str; 4] = ["ID3", "TAG", "OGGS", "MP+"];
// https://wiki.hydrogenaud.io/index.php?title=APE_Tags_Header

View file

@ -10,7 +10,6 @@ use byteorder::{LittleEndian, ReadBytesExt};
#[derive(Copy, Clone)]
pub(crate) struct ApeHeader {
pub(crate) size: u32,
#[cfg(feature = "ape")]
pub(crate) item_count: u32,
}
@ -28,12 +27,8 @@ where
decode_err!(@BAIL APE, "APE tag has an invalid size (< 32)");
}
#[cfg(feature = "ape")]
let item_count = data.read_u32::<LittleEndian>()?;
#[cfg(not(feature = "ape"))]
data.seek(SeekFrom::Current(4))?;
if footer {
// No point in reading the rest of the footer, just seek back to the end of the header
data.seek(SeekFrom::Current(i64::from(size - 12).neg()))?;
@ -54,9 +49,5 @@ where
decode_err!(@BAIL APE, "APE tag has an invalid size (> file size)");
}
Ok(ApeHeader {
size,
#[cfg(feature = "ape")]
item_count,
})
Ok(ApeHeader { size, item_count })
}

View file

@ -9,6 +9,7 @@ pub(crate) mod constants;
pub(crate) mod header;
mod properties;
mod read;
pub(crate) mod tag;
use crate::id3::v1::tag::ID3v1Tag;
#[cfg(feature = "id3v2")]
@ -18,17 +19,10 @@ use lofty_attr::LoftyFile;
// Exports
cfg_if::cfg_if! {
if #[cfg(feature = "ape")] {
pub(crate) mod tag;
pub use tag::ApeTag;
pub use tag::item::ApeItem;
pub use crate::picture::APE_PICTURE_TYPES;
}
}
pub use crate::picture::APE_PICTURE_TYPES;
pub use properties::ApeProperties;
pub use tag::item::ApeItem;
pub use tag::ApeTag;
/// An APE file
#[derive(LoftyFile)]
@ -43,7 +37,6 @@ pub struct ApeFile {
#[lofty(tag_type = "ID3v2")]
pub(crate) id3v2_tag: Option<ID3v2Tag>,
/// An APEv1/v2 tag
#[cfg(feature = "ape")]
#[lofty(tag_type = "APE")]
pub(crate) ape_tag: Option<ApeTag>,
/// The file's audio properties

View file

@ -1,7 +1,7 @@
use super::constants::APE_PREAMBLE;
use super::header::read_ape_header;
#[cfg(feature = "ape")]
use super::tag::{read::read_ape_tag, ApeTag};
use super::tag::read::read_ape_tag;
use super::tag::ApeTag;
use super::{ApeFile, ApeProperties};
use crate::error::Result;
use crate::id3::v1::tag::ID3v1Tag;
@ -27,7 +27,6 @@ where
#[cfg(feature = "id3v2")]
let mut id3v2_tag: Option<ID3v2Tag> = None;
let mut id3v1_tag: Option<ID3v1Tag> = None;
#[cfg(feature = "ape")]
let mut ape_tag: Option<ApeTag> = None;
// ID3v2 tags are unsupported in APE files, but still possible
@ -81,14 +80,8 @@ where
let ape_header = read_ape_header(data, false)?;
stream_len -= u64::from(ape_header.size);
#[cfg(feature = "ape")]
{
let ape = read_ape_tag(data, ape_header)?;
ape_tag = Some(ape)
}
#[cfg(not(feature = "ape"))]
data.seek(SeekFrom::Current(ape_header.size as i64))?;
let ape = read_ape_tag(data, ape_header)?;
ape_tag = Some(ape);
},
_ => {
decode_err!(@BAIL APE, "Invalid data found while reading header, expected any of [\"MAC \", \"APETAGEX\", \"ID3\"]")
@ -129,14 +122,8 @@ where
let ape_header = read_ape_header(data, true)?;
stream_len -= u64::from(ape_header.size);
#[cfg(feature = "ape")]
{
let ape = read_ape_tag(data, ape_header)?;
ape_tag = Some(ape)
}
#[cfg(not(feature = "ape"))]
data.seek(SeekFrom::Current(ape_header.size as i64))?;
let ape = read_ape_tag(data, ape_header)?;
ape_tag = Some(ape);
}
let file_length = data.stream_position()?;
@ -148,7 +135,6 @@ where
id3v1_tag,
#[cfg(feature = "id3v2")]
id3v2_tag,
#[cfg(feature = "ape")]
ape_tag,
properties: if parse_options.read_properties {
super::properties::read_properties(data, stream_len, file_length)?

View file

@ -830,7 +830,6 @@ impl FileType {
{
true
},
#[cfg(feature = "ape")]
FileType::APE | FileType::MPEG | FileType::WavPack if tag_type == TagType::APE => true,
FileType::Opus | FileType::FLAC | FileType::Vorbis | FileType::Speex => {
tag_type == TagType::VorbisComments

View file

@ -7,7 +7,6 @@ mod read;
pub use header::{ChannelMode, Emphasis, Layer, MpegVersion};
pub use properties::MPEGProperties;
#[cfg(feature = "ape")]
use crate::ape::tag::ApeTag;
use crate::id3::v1::tag::ID3v1Tag;
#[cfg(feature = "id3v2")]
@ -28,7 +27,6 @@ pub struct MPEGFile {
#[lofty(tag_type = "ID3v1")]
pub(crate) id3v1_tag: Option<ID3v1Tag>,
/// An APEv1/v2 tag
#[cfg(feature = "ape")]
#[lofty(tag_type = "APE")]
pub(crate) ape_tag: Option<ApeTag>,
/// The file's audio properties

View file

@ -2,7 +2,6 @@ use super::header::{cmp_header, search_for_frame_sync, Header, HeaderCmpResult,
use super::{MPEGFile, MPEGProperties};
use crate::ape::constants::APE_PREAMBLE;
use crate::ape::header::read_ape_header;
#[cfg(feature = "ape")]
use crate::ape::tag::read::read_ape_tag;
use crate::error::Result;
#[cfg(feature = "id3v2")]
@ -71,17 +70,7 @@ where
if &header_remaining == b"AGEX" {
let ape_header = read_ape_header(reader, false)?;
#[cfg(not(feature = "ape"))]
{
let size = ape_header.size;
reader.seek(SeekFrom::Current(size as i64))?;
}
#[cfg(feature = "ape")]
{
file.ape_tag =
Some(crate::ape::tag::read::read_ape_tag(reader, ape_header)?);
}
file.ape_tag = Some(crate::ape::tag::read::read_ape_tag(reader, ape_header)?);
continue;
}
@ -124,11 +113,8 @@ where
let ape_header = read_ape_header(reader, true)?;
let size = ape_header.size;
#[cfg(feature = "ape")]
{
let ape = read_ape_tag(reader, ape_header)?;
file.ape_tag = Some(ape);
}
let ape = read_ape_tag(reader, ape_header)?;
file.ape_tag = Some(ape);
// Seek back to the start of the tag
let pos = reader.stream_position()?;

View file

@ -8,24 +8,21 @@ use crate::{
use std::borrow::Cow;
use std::fmt::{Debug, Formatter};
#[cfg(any(feature = "ape", feature = "id3v2"))]
#[cfg(any(feature = "id3v2"))]
use std::io::Cursor;
use std::io::Read;
#[cfg(feature = "id3v2")]
use std::io::Write;
#[cfg(any(feature = "ape"))]
use std::io::{Seek, SeekFrom};
use std::io::{Read, Seek, SeekFrom};
#[cfg(feature = "id3v2")]
use crate::util::text::TextEncoding;
use byteorder::BigEndian;
#[cfg(any(feature = "id3v2", feature = "ape"))]
#[cfg(any(feature = "id3v2"))]
use byteorder::ReadBytesExt;
#[cfg(feature = "id3v2")]
use byteorder::WriteBytesExt;
/// Common picture item keys for APE
#[cfg(feature = "ape")]
pub const APE_PICTURE_TYPES: [&str; 21] = [
"Cover Art (Other)",
"Cover Art (Png Icon)",
@ -205,7 +202,6 @@ impl PictureType {
// APE specific methods
#[cfg(feature = "ape")]
/// Get an APE item key from a `PictureType`
pub fn as_ape_key(&self) -> Option<&str> {
match self {
@ -234,7 +230,6 @@ impl PictureType {
}
}
#[cfg(feature = "ape")]
/// Get a `PictureType` from an APE item key
pub fn from_ape_key(key: &str) -> Self {
match key {
@ -827,7 +822,6 @@ impl Picture {
err!(NotAPicture)
}
#[cfg(feature = "ape")]
/// Convert a [`Picture`] to an APE Cover Art byte vec:
///
/// NOTE: This is only the picture data and description, a
@ -846,7 +840,6 @@ impl Picture {
data
}
#[cfg(feature = "ape")]
/// Get a [`Picture`] from an APEv2 binary item:
///
/// NOTE: This function expects `bytes` to contain *only* the APE item data

View file

@ -72,7 +72,6 @@ gen_map!(
);
gen_map!(
#[cfg(feature = "ape")]
APE_MAP;
"Album" => AlbumTitle,
@ -419,7 +418,6 @@ gen_item_keys!(
#[cfg(feature = "aiff_text_chunks")]
[TagType::AIFFText, AIFF_TEXT_MAP],
#[cfg(feature = "ape")]
[TagType::APE, APE_MAP],
#[cfg(feature = "id3v2")]

View file

@ -9,7 +9,6 @@ use crate::id3::v1::tag::Id3v1TagRef;
use crate::id3::v2::{self, tag::Id3v2TagRef, ID3v2TagFlags};
use crate::mp4::Ilst;
use crate::ogg::tag::{create_vorbis_comments_ref, VorbisCommentsRef};
#[cfg(feature = "ape")]
use ape::tag::ApeTagRef;
#[cfg(feature = "aiff_text_chunks")]
use iff::aiff::tag::AiffTextChunksRef;
@ -42,7 +41,6 @@ pub(crate) fn write_tag(tag: &Tag, file: &mut File, file_type: FileType) -> Resu
#[allow(unreachable_patterns)]
pub(crate) fn dump_tag<W: Write>(tag: &Tag, writer: &mut W) -> Result<()> {
match tag.tag_type() {
#[cfg(feature = "ape")]
TagType::APE => ApeTagRef {
read_only: false,
items: ape::tag::tagitems_into_ape(tag.items()),

View file

@ -2,7 +2,6 @@
mod properties;
mod read;
#[cfg(feature = "ape")]
use crate::ape::tag::ApeTag;
use crate::id3::v1::tag::ID3v1Tag;
@ -20,7 +19,6 @@ pub struct WavPackFile {
#[lofty(tag_type = "ID3v1")]
pub(crate) id3v1_tag: Option<ID3v1Tag>,
/// An APEv1/v2 tag
#[cfg(feature = "ape")]
#[lofty(tag_type = "APE")]
pub(crate) ape_tag: Option<ApeTag>,
/// The file's audio properties

View file

@ -18,7 +18,6 @@ where
reader.seek(SeekFrom::Start(current_pos))?;
let mut id3v1_tag = None;
#[cfg(feature = "ape")]
let mut ape_tag = None;
let ID3FindResults(id3v1_header, id3v1) = find_id3v1(reader, true)?;
@ -49,19 +48,12 @@ where
let ape_header = read_ape_header(reader, true)?;
stream_length -= u64::from(ape_header.size);
#[cfg(feature = "ape")]
{
let ape = read_ape_tag(reader, ape_header)?;
ape_tag = Some(ape)
}
#[cfg(not(feature = "ape"))]
data.seek(SeekFrom::Current(ape_header.size as i64))?;
let ape = read_ape_tag(reader, ape_header)?;
ape_tag = Some(ape);
}
Ok(WavPackFile {
id3v1_tag,
#[cfg(feature = "ape")]
ape_tag,
properties: if parse_options.read_properties {
super::properties::read_properties(reader, stream_length, parse_options.parsing_mode)?