Commit e9a294e6 authored by schreibfaul1's avatar schreibfaul1

VORBIS COMMENTS for FLAC

parent f829f30d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Created on: Oct 26.2018 * Created on: Oct 26.2018
* *
* Version 3.0.8v * Version 3.0.8w
* Updated on: Apr 01.2024 * Updated on: Apr 01.2024
* Author: Wolle (schreibfaul1) * Author: Wolle (schreibfaul1)
* *
...@@ -1544,48 +1544,30 @@ int Audio::read_FLAC_Header(uint8_t* data, size_t len) { ...@@ -1544,48 +1544,30 @@ int Audio::read_FLAC_Header(uint8_t* data, size_t len) {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(m_controlCounter == FLAC_VORBIS) { /* VORBIS COMMENT */ // field names if(m_controlCounter == FLAC_VORBIS) { /* VORBIS COMMENT */ // field names
const char fn[12][17] = {"ALBUMARTIST=", "ALBUMARTISTSORT=", "ARTISTSORT=", "TOTALTRACKS=", "TITLE=", "VERSION=", "ALBUM=", "TRACKNUMBER=", "ARTIST=", "COMMENT=", "GENRE=", "DATE="};
int offset;
size_t vendorLength = bigEndian(data, 3); size_t vendorLength = bigEndian(data, 3);
data += 3; size_t idx = 0;
size_t vendorStringLength = data[0]; data += 3; idx += 3;
vendorStringLength += data[1] << 8; size_t vendorStringLength = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24);
vendorStringLength += data[2] << 16; if(vendorStringLength) {data += 4; idx += 4;}
vendorStringLength += data[3] << 24;
if(vendorStringLength) data += 4;
if(vendorStringLength > 495) vendorStringLength = 495; // guard if(vendorStringLength > 495) vendorStringLength = 495; // guard
strcpy(m_chbuf, "VENDOR_STRING: "); strcpy(m_chbuf, "VENDOR_STRING: ");
strncpy(m_chbuf + 15, (const char*)data, vendorStringLength); strncpy(m_chbuf + 15, (const char*)data, vendorStringLength);
m_chbuf[15 + vendorStringLength] = '\0'; m_chbuf[15 + vendorStringLength] = '\0';
if(audio_id3data) audio_id3data(m_chbuf); if(audio_id3data) audio_id3data(m_chbuf);
data += vendorStringLength; data += vendorStringLength; idx += vendorStringLength;
size_t commentListLength = +data[0]; size_t commentListLength = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24);
commentListLength += data[1]; data += 4; idx += 4;
commentListLength += data[2];
commentListLength += data[3];
data += 4;
uint32_t s = 0;
for(int i = 0; i < commentListLength; i++) { for(int i = 0; i < commentListLength; i++) {
for(int j = 0; j < 12; j++) { (void)i;
offset = specialIndexOf(data, fn[j], len); size_t commentLength = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24);
if(offset == 4) { data += 4; idx += 4;
s = data[offset - 4]; if(commentLength > 512) commentLength = 512; // guard
s += data[offset - 3] << 8; strncpy(m_chbuf, (const char *)data , commentLength);
s += data[offset - 2] << 16; m_chbuf[commentLength] = '\0';
s += data[offset - 1] << 24;
if(s > 512) s = 512; // guard
memset(m_chbuf, 0, 512);
strcpy(m_chbuf, fn[j]);
int p = strlen(m_chbuf);
m_chbuf[p - 1] = ':';
m_chbuf[p] = ' ';
strncat(m_chbuf, (const char*)(data + offset + p), (s - p));
if(audio_id3data) audio_id3data(m_chbuf); if(audio_id3data) audio_id3data(m_chbuf);
} data += commentLength; idx += commentLength;
} if(idx > vendorLength + 3) {log_e("VORBIS COMMENT section is too long");}
data += s + 4;
} }
m_controlCounter = FLAC_MBH; m_controlCounter = FLAC_MBH;
retvalue = vendorLength + 3; retvalue = vendorLength + 3;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment