[3/4] Completely remove HWCODEC support

'swcodec' is now always set (and recording_swcodec for recording-capable
units) in feature.txt so the manual and language strings don't need to
all be fixed up.

Change-Id: Ib2c9d5d157af8d33653e2d4b4a12881b9aa6ddb0
This commit is contained in:
Solomon Peachy 2020-07-17 00:01:32 -04:00
parent 0c4f89370d
commit 8cb555460f
207 changed files with 322 additions and 5594 deletions

View file

@ -43,9 +43,7 @@
#include "metadata.h"
#include "mp3data.h"
#if CONFIG_CODEC == SWCODEC
#include "metadata_common.h"
#endif
#include "metadata_parsers.h"
#include "misc.h"
@ -91,9 +89,6 @@ static const char* const genres[] = {
"Synthpop"
};
#if CONFIG_CODEC != SWCODEC
static
#endif
char* id3_get_num_genre(unsigned int genre_num)
{
if (genre_num < ARRAYLEN(genres))
@ -376,23 +371,20 @@ static int parseuser( struct mp3entry* entry, char* tag, int bufferpos )
/* At least part of the value was read, so we can safely try to
* parse it */
value = tag + desc_len + 1;
if (!strcasecmp(tag, "ALBUM ARTIST")) {
length = strlen(value) + 1;
strlcpy(tag, value, length);
entry->albumartist = tag;
#if CONFIG_CODEC == SWCODEC
} else {
/* Call parse_replaygain(). */
parse_replaygain(tag, value, entry);
#endif
}
}
return tag - entry->id3v2buf + length;
}
#if CONFIG_CODEC == SWCODEC
/* parse RVA2 binary data and convert to replaygain information. */
static int parserva2( struct mp3entry* entry, char* tag, int bufferpos)
{
@ -452,13 +444,12 @@ static int parserva2( struct mp3entry* entry, char* tag, int bufferpos)
return start_pos;
}
}
parse_replaygain_int(album, gain, peak * 2, entry);
}
return start_pos;
}
#endif
static int parsembtid( struct mp3entry* entry, char* tag, int bufferpos )
{
@ -514,9 +505,7 @@ static const struct tag_resolver taglist[] = {
{ "PIC", 3, 0, &parsealbumart, true },
#endif
{ "TXXX", 4, 0, &parseuser, false },
#if CONFIG_CODEC == SWCODEC
{ "RVA2", 4, 0, &parserva2, true },
#endif
{ "UFID", 4, 0, &parsembtid, false },
};
@ -738,9 +727,7 @@ void setid3v2title(int fd, struct mp3entry *entry)
bool unsynch = false;
int i, j;
int rc;
#if CONFIG_CODEC == SWCODEC
bool itunes_gapless = false;
#endif
#ifdef HAVE_ALBUMART
entry->has_embedded_albumart = false;
@ -984,14 +971,11 @@ void setid3v2title(int fd, struct mp3entry *entry)
(tr->tag_length == 3 && !memcmp( header, "COM", 3))) {
int offset;
if(bytesread >= 8 && !strncmp(tag+4, "iTun", 4)) {
#if CONFIG_CODEC == SWCODEC
/* check for iTunes gapless information */
if(bytesread >= 12 && !strncmp(tag+4, "iTunSMPB", 8))
itunes_gapless = true;
else
#endif
/* ignore other with iTunes tags */
break;
break; /* ignore other with iTunes tags */
}
offset = 3 + unicode_len(*tag, tag + 4);
@ -1071,7 +1055,6 @@ void setid3v2title(int fd, struct mp3entry *entry)
tag[bytesread] = 0;
bufferpos += bytesread + 1;
#if CONFIG_CODEC == SWCODEC
/* parse the tag if it contains iTunes gapless info */
if (itunes_gapless)
{
@ -1079,7 +1062,6 @@ void setid3v2title(int fd, struct mp3entry *entry)
entry->lead_trim = get_itunes_int32(tag, 1);
entry->tail_trim = get_itunes_int32(tag, 2);
}
#endif
/* Note that parser functions sometimes set *ptag to NULL, so
* the "!*ptag" check here doesn't always have the desired

View file

@ -29,8 +29,6 @@
#include "metadata_parsers.h"
#if CONFIG_CODEC == SWCODEC
/* For trailing tag stripping and base audio data types */
#include "buffering.h"
@ -53,7 +51,6 @@ static bool get_other_asap_metadata(int fd, struct mp3entry *id3)
id3->genre_string = id3_get_num_genre(36);
return true;
}
#endif /* CONFIG_CODEC == SWCODEC */
bool write_metadata_log = false;
const struct afmt_entry audio_formats[AFMT_NUM_CODECS] =
@ -66,13 +63,7 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] =
[AFMT_MPA_L2] =
AFMT_ENTRY("MP2", "mpa", NULL, get_mp3_metadata, "mpa\0mp2\0"),
#if CONFIG_CODEC != SWCODEC
/* MPEG Audio layer 3 on HWCODEC: .talk clips, no encoder */
[AFMT_MPA_L3] =
AFMT_ENTRY("MP3", "mpa", NULL, get_mp3_metadata, "mp3\0talk\0"),
#else /* CONFIG_CODEC == SWCODEC */
/* MPEG Audio layer 3 on SWCODEC */
/* MPEG Audio layer 3 */
[AFMT_MPA_L3] =
AFMT_ENTRY("MP3", "mpa", "mp3_enc", get_mp3_metadata, "mp3\0"),
@ -238,10 +229,9 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] =
/* AAC bitstream format */
[AFMT_AAC_BSF] =
AFMT_ENTRY("AAC", "aac_bsf", NULL, get_aac_metadata, "aac\0"),
#endif
};
#if CONFIG_CODEC == SWCODEC && defined (HAVE_RECORDING)
#if defined (HAVE_RECORDING)
/* get REC_FORMAT_* corresponding AFMT_* */
const int rec_format_afmt[REC_NUM_FORMATS] =
{
@ -267,9 +257,8 @@ const int afmt_rec_format[AFMT_NUM_CODECS] =
[AFMT_PCM_WAV] = REC_FORMAT_PCM_WAV,
};
#endif
#endif /* CONFIG_CODEC == SWCODEC && defined (HAVE_RECORDING) */
#endif /* defined (HAVE_RECORDING) */
#if CONFIG_CODEC == SWCODEC
/* Get the canonical AFMT type */
int get_audio_base_codec_type(int type)
{
@ -357,8 +346,6 @@ bool format_buffers_with_offset(int afmt)
return false;
}
}
#endif /* CONFIG_CODEC == SWCODEC */
/* Simple file type probing by looking at the filename extension. */
unsigned int probe_file_format(const char *filename)
@ -464,7 +451,6 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname)
}
#ifndef __PCTOOL__
#if CONFIG_CODEC == SWCODEC
void strip_tags(int handle_id)
{
static const unsigned char tag[] = "TAG";
@ -500,7 +486,6 @@ void strip_tags(int handle_id)
logf("Cutting off APE tag (%ldB)", len);
bufcuttail(handle_id, len);
}
#endif /* CONFIG_CODEC == SWCODEC */
#endif /* ! __PCTOOL__ */
#define MOVE_ENTRY(x) if (x) x += offset;
@ -544,7 +529,6 @@ void wipe_mp3entry(struct mp3entry *id3)
memset(id3, 0, sizeof (struct mp3entry));
}
#if CONFIG_CODEC == SWCODEC
/* Glean what is possible from the filename alone - does not parse metadata */
void fill_metadata_from_path(struct mp3entry *id3, const char *trackname)
{
@ -574,4 +558,3 @@ void fill_metadata_from_path(struct mp3entry *id3, const char *trackname)
/* Copy the path info */
strlcpy(id3->path, trackname, sizeof (id3->path));
}
#endif /* CONFIG_CODEC == SWCODEC */

View file

@ -37,7 +37,6 @@ enum
AFMT_MPA_L2, /* MPEG Audio layer 2 */
AFMT_MPA_L3, /* MPEG Audio layer 3 */
#if CONFIG_CODEC == SWCODEC
AFMT_AIFF, /* Audio Interchange File Format */
AFMT_PCM_WAV, /* Uncompressed PCM in a WAV file */
AFMT_OGG_VORBIS, /* Ogg Vorbis */
@ -91,7 +90,6 @@ enum
AFMT_KSS, /* KSS (MSX computer KSS Music File) */
AFMT_OPUS, /* Opus (see http://www.opus-codec.org ) */
AFMT_AAC_BSF,
#endif
/* add new formats at any index above this line to have a sensible order -
specified array index inits are used */
@ -99,7 +97,7 @@ enum
AFMT_NUM_CODECS,
#if CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING)
#if defined(HAVE_RECORDING)
/* masks to decompose parts */
CODEC_AFMT_MASK = 0x0fff,
CODEC_TYPE_MASK = 0x7000,
@ -107,10 +105,9 @@ enum
/* switch for specifying codec type when requesting a filename */
CODEC_TYPE_DECODER = (0 << 12), /* default */
CODEC_TYPE_ENCODER = (1 << 12),
#endif /* CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING) */
#endif /* defined(HAVE_RECORDING) */
};
#if CONFIG_CODEC == SWCODEC
#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
#define CODEC_EXTENSION "so"
#define CODEC_PREFIX "lib"
@ -157,23 +154,15 @@ extern const int rec_format_afmt[REC_NUM_FORMATS];
{ label, root_fname, func, ext_list }
#endif /* HAVE_RECORDING */
#else /* !SWCODEC */
#define AFMT_ENTRY(label, root_fname, enc_root_fname, func, ext_list) \
{ label, func, ext_list }
#endif /* CONFIG_CODEC == SWCODEC */
/** Database of audio formats **/
/* record describing the audio format */
struct mp3entry;
struct afmt_entry
{
const char *label; /* format label */
#if CONFIG_CODEC == SWCODEC
const char *codec_root_fn; /* root codec filename (sans _enc and .codec) */
#ifdef HAVE_RECORDING
const char *codec_enc_root_fn; /* filename of encoder codec */
#endif
#endif
bool (*parse_func)(int fd, struct mp3entry *id3); /* return true on success */
const char *ext_list; /* NULL terminated extension
@ -305,14 +294,12 @@ struct mp3entry {
#endif
/* replaygain support */
#if CONFIG_CODEC == SWCODEC
long track_level; /* holds the level in dB * (1<<FP_BITS) */
long album_level;
long track_gain; /* s19.12 signed fixed point. 0 for no gain. */
long album_gain;
long track_peak; /* s19.12 signed fixed point. 0 for no peak. */
long album_peak;
#endif
#ifdef HAVE_ALBUMART
bool has_embedded_albumart;
@ -335,13 +322,11 @@ void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig);
void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig);
void wipe_mp3entry(struct mp3entry *id3);
#if CONFIG_CODEC == SWCODEC
void fill_metadata_from_path(struct mp3entry *id3, const char *trackname);
int get_audio_base_codec_type(int type);
void strip_tags(int handle_id);
bool rbcodec_format_is_atomic(int afmt);
bool format_buffers_with_offset(int afmt);
#endif
#endif

View file

@ -19,15 +19,12 @@
*
****************************************************************************/
#if CONFIG_CODEC == SWCODEC
char* id3_get_num_genre(unsigned int genre_num);
#endif
int getid3v1len(int fd);
int getid3v2len(int fd);
bool setid3v1title(int fd, struct mp3entry *entry);
void setid3v2title(int fd, struct mp3entry *entry);
bool get_mp3_metadata(int fd, struct mp3entry* id3);
#if CONFIG_CODEC == SWCODEC
bool get_adx_metadata(int fd, struct mp3entry* id3);
bool get_aiff_metadata(int fd, struct mp3entry* id3);
bool get_flac_metadata(int fd, struct mp3entry* id3);
@ -58,4 +55,3 @@ bool get_sgc_metadata(int fd, struct mp3entry* id3);
bool get_vgm_metadata(int fd, struct mp3entry* id3);
bool get_kss_metadata(int fd, struct mp3entry* id3);
bool get_aac_metadata(int fd, struct mp3entry* id3);
#endif /* CONFIG_CODEC == SWCODEC */

View file

@ -108,11 +108,9 @@ static int getsonglength(int fd, struct mp3entry *entry)
entry->frequency = info.frequency;
entry->layer = info.layer;
switch(entry->layer) {
#if CONFIG_CODEC==SWCODEC
case 0:
entry->codectype=AFMT_MPA_L1;
break;
#endif
case 1:
entry->codectype=AFMT_MPA_L2;
break;
@ -143,12 +141,10 @@ static int getsonglength(int fd, struct mp3entry *entry)
entry->vbr = info.is_vbr;
entry->has_toc = info.has_toc;
#if CONFIG_CODEC==SWCODEC
if (!entry->lead_trim)
entry->lead_trim = info.enc_delay;
if (!entry->tail_trim)
entry->tail_trim = info.enc_padding;
#endif
memcpy(entry->toc, info.toc, sizeof(info.toc));

View file

@ -115,11 +115,6 @@ static bool is_mp3frameheader(unsigned long head)
return false;
if (!(head & LAYER_MASK)) /* no layer? */
return false;
#if CONFIG_CODEC != SWCODEC
/* The MAS can't decode layer 1, so treat layer 1 data as invalid */
if ((head & LAYER_MASK) == LAYER_MASK)
return false;
#endif
if ((head & BITRATE_MASK) == BITRATE_MASK) /* bad bitrate? */
return false;
if (!(head & BITRATE_MASK)) /* no bitrate? */
@ -454,7 +449,6 @@ static void get_xing_info(struct mp3info *info, unsigned char *buf)
/* We don't care about this, but need to skip it */
i += 4;
}
#if CONFIG_CODEC==SWCODEC
i += 21;
info->enc_delay = ((int)buf[i ] << 4) | (buf[i+1] >> 4);
info->enc_padding = ((int)(buf[i+1]&0xF) << 8) | buf[i+2];
@ -467,7 +461,6 @@ static void get_xing_info(struct mp3info *info, unsigned char *buf)
info->enc_delay = -1;
info->enc_padding = -1;
}
#endif
}
/* Extract information from a 'VBRI' header. */
@ -541,18 +534,16 @@ int get_mp3file_info(int fd, struct mp3info *info)
/* Initialize info and frame */
memset(info, 0, sizeof(struct mp3info));
memset(frame, 0, sizeof(frame));
#if CONFIG_CODEC==SWCODEC
/* These two are needed for proper LAME gapless MP3 playback */
info->enc_delay = -1;
info->enc_padding = -1;
#endif
/* Get the very first single MPEG frame. */
result = get_next_header_info(fd, &bytecount, info, true);
if(result)
return result;
/* Read the amount of frame data to the buffer that is required for the
* vbr tag parsing. Skip the rest. */
buf_size = MIN(info->frame_size-4, (int)sizeof(frame));