Skip to content

Commit

Permalink
+ ID3v2: Popularimeter
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeMartinez committed Jun 16, 2022
1 parent 78274e6 commit 9761b0f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Source/MediaInfo/MediaInfo_Config_Automatic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ void MediaInfo_Config_DefaultLanguage (Translation &Info)
" second1; second\n"
" second2; seconds\n"
" second3; seconds\n"
" star1; star\n"
" star2; stars\n"
" star3; stars\n"
" text stream1; text stream\n"
" text stream2; text streams\n"
" text stream3; text streams\n"
Expand Down
42 changes: 42 additions & 0 deletions Source/MediaInfo/Tag/File_Id3v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,48 @@ void File_Id3v2::RGAD()
FILLING_END();
}

//---------------------------------------------------------------------------
void File_Id3v2::POPM()
{
string Owner;
size_t Owner_Size=0;
int8u Rating;
while (Element_Offset+Owner_Size<Element_Size && Buffer[Buffer_Offset+(size_t)Element_Offset+Owner_Size]!='\0')
Owner_Size++;
if (Owner_Size==0 || Element_Offset+Owner_Size>=Element_Size)
{
Skip_XX(Element_Size-Element_Offset, "Unknown");
return;
}
Get_String(Owner_Size, Owner, "Owner identifier");
Skip_B1( "Null");
Get_B1 (Rating, "Rating");
if (Element_Offset<Element_Size)
Skip_B4( "Counter");

FILLING_BEGIN();
if (Rating)
{
int8u Limits[]={31, 95, 159, 223, 255};
int8u Limit=0;
while (Rating>Limits[Limit])
Limit++;
Limit++;
Fill(Stream_General, 0, "Popularimeter", Limit);
Fill(Stream_General, 0, "Popularimeter_Numerator", Rating);
Fill(Stream_General, 0, "Popularimeter_Denominator", 255);
Fill(Stream_General, 0, "Popularimeter_Source", Owner);
auto const& Popularimeter=Retrieve_Const(Stream_General, 0, "Popularimeter");
Fill(Stream_General, 0, "Popularimeter/String", MediaInfoLib::Config.Language_Get(Popularimeter, __T(" star"))+__T(" (")+Retrieve_Const(Stream_General, 0, "Popularimeter_Numerator")+__T("/255, ")+Retrieve_Const(Stream_General, 0, "Popularimeter_Source") + __T(')'));
Fill_SetOptions(Stream_General, 0, "Popularimeter", "N NIY");
Fill_SetOptions(Stream_General, 0, "Popularimeter_Numerator", "N NIY");
Fill_SetOptions(Stream_General, 0, "Popularimeter_Denominator", "N NIY");
Fill_SetOptions(Stream_General, 0, "Popularimeter_Source", "N NTY");
Fill_SetOptions(Stream_General, 0, "Popularimeter/String", "Y NTN");
}
FILLING_END();
}

//---------------------------------------------------------------------------
void File_Id3v2::PRIV()
{
Expand Down
4 changes: 2 additions & 2 deletions Source/MediaInfo/Tag/File_Id3v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private :
void MLLT() {Skip_XX(Element_Size, "Data");}
void OWNE() {Skip_XX(Element_Size, "Data");}
void PCNT() {Skip_XX(Element_Size, "Data");}
void POPM() {Skip_XX(Element_Size, "Data");}
void POPM();
void POSS() {Skip_XX(Element_Size, "Data");}
void PRIV();
void RBUF() {Skip_XX(Element_Size, "Data");}
Expand Down Expand Up @@ -163,7 +163,7 @@ private :
void MCI() {Skip_XX(Element_Size, "Data");}
void MLL() {Skip_XX(Element_Size, "Data");}
void PIC_() {APIC();}
void POP() {Skip_XX(Element_Size, "Data");}
void POP() {POPM();}
void REV() {Skip_XX(Element_Size, "Data");}
void RVA() {Skip_XX(Element_Size, "Data");}
void SLT() {Skip_XX(Element_Size, "Data");}
Expand Down
3 changes: 3 additions & 0 deletions Source/Resource/Text/Language/DefaultLanguage.csv
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
second1; second
second2; seconds
second3; seconds
star1; star
star2; stars
star3; stars
text stream1; text stream
text stream2; text streams
text stream3; text streams
Expand Down

0 comments on commit 9761b0f

Please sign in to comment.