forked from len0rd/rockbox
metadata: mp3: Support unsync embedded jpeg album art
Support parsing alubm art from id3 metadata with "unsynchronisation scheme": https://id3.org/id3v2.3.0#The_unsynchronisation_scheme Change-Id: I1e2ca4ae0aa967f7e80142a04c9a7d99e38e68b2
This commit is contained in:
parent
6649731563
commit
7f4a8891a6
7 changed files with 72 additions and 23 deletions
23
lib/rbcodec/metadata/embedded_metadata.h
Normal file
23
lib/rbcodec/metadata/embedded_metadata.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2024 Roman Artiukhin
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <stdbool.h>
|
||||
|
||||
int id3_unsynchronize(char* tag, int len, bool *ff_found);
|
|
@ -45,6 +45,7 @@
|
|||
#include "mp3data.h"
|
||||
#include "metadata_common.h"
|
||||
#include "metadata_parsers.h"
|
||||
#include "embedded_metadata.h"
|
||||
#include "misc.h"
|
||||
|
||||
static unsigned long unsync(unsigned long b0,
|
||||
|
@ -161,7 +162,8 @@ struct tag_resolver {
|
|||
|
||||
static bool global_ff_found;
|
||||
|
||||
static int unsynchronize(char* tag, int len, bool *ff_found)
|
||||
#define unsynchronize id3_unsynchronize
|
||||
int id3_unsynchronize(char* tag, int len, bool *ff_found)
|
||||
{
|
||||
int i;
|
||||
unsigned char c;
|
||||
|
@ -299,9 +301,7 @@ static int parsealbumart( struct mp3entry* entry, char* tag, int bufferpos )
|
|||
if(entry->has_embedded_albumart)
|
||||
return bufferpos;
|
||||
|
||||
/* we currently don't support unsynchronizing albumart */
|
||||
if (entry->albumart.type == AA_TYPE_UNSYNC)
|
||||
return bufferpos;
|
||||
bool unsync = entry->albumart.type == AA_FLAG_ID3_UNSYNC;
|
||||
|
||||
entry->albumart.type = AA_TYPE_UNKNOWN;
|
||||
|
||||
|
@ -353,6 +353,10 @@ static int parsealbumart( struct mp3entry* entry, char* tag, int bufferpos )
|
|||
/* fixup offset&size for image data */
|
||||
entry->albumart.pos += tag - start;
|
||||
entry->albumart.size -= tag - start;
|
||||
if (unsync)
|
||||
{
|
||||
entry->albumart.type |= AA_FLAG_ID3_UNSYNC;
|
||||
}
|
||||
/* check for malformed tag with no picture data */
|
||||
entry->has_embedded_albumart = (entry->albumart.size != 0);
|
||||
}
|
||||
|
@ -1142,14 +1146,11 @@ retry_with_limit:
|
|||
((tr->tag_length == 4 && !memcmp( header, "APIC", 4)) ||
|
||||
(tr->tag_length == 3 && !memcmp( header, "PIC" , 3))))
|
||||
{
|
||||
if (unsynch || (global_unsynch && version <= ID3_VER_2_3))
|
||||
entry->albumart.type = AA_TYPE_UNSYNC;
|
||||
else
|
||||
{
|
||||
entry->albumart.pos = lseek(fd, 0, SEEK_CUR) - framelen;
|
||||
entry->albumart.size = totframelen;
|
||||
entry->albumart.type = AA_TYPE_UNKNOWN;
|
||||
}
|
||||
entry->albumart.pos = lseek(fd, 0, SEEK_CUR) - framelen;
|
||||
entry->albumart.size = totframelen;
|
||||
entry->albumart.type = (unsynch || (global_unsynch && version <= ID3_VER_2_3))
|
||||
? AA_FLAG_ID3_UNSYNC
|
||||
: AA_TYPE_UNKNOWN;
|
||||
}
|
||||
#endif
|
||||
if( tr->ppFunc )
|
||||
|
|
|
@ -196,13 +196,17 @@ enum {
|
|||
ID3_VER_2_4
|
||||
};
|
||||
|
||||
#define AA_FLAGS_SHIFT 4
|
||||
#define AA_CLEAR_FLAGS_MASK ~(-1 << AA_FLAGS_SHIFT)
|
||||
|
||||
#ifdef HAVE_ALBUMART
|
||||
enum mp3_aa_type {
|
||||
AA_TYPE_UNSYNC = -1,
|
||||
AA_TYPE_UNKNOWN,
|
||||
AA_TYPE_BMP,
|
||||
AA_TYPE_PNG,
|
||||
AA_TYPE_JPG,
|
||||
|
||||
AA_FLAG_ID3_UNSYNC = 1 << (AA_FLAGS_SHIFT + 0),
|
||||
};
|
||||
|
||||
struct mp3_albumart {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue