@@ -799,6 +799,70 @@ namespace MP4{
799799 return r.str ();
800800 }
801801
802+
803+ AV1C::AV1C (){
804+ memcpy (data + 4 , " av1C" , 4 );
805+ setInt8 (0b10000001 , 0 ); // Marker 1, version 1: 0b10000001
806+ }
807+
808+ std::string AV1C::toPrettyString (uint32_t indent){
809+ std::stringstream r;
810+ r << std::string (indent, ' ' ) << " [av1C] AV1 Init Data (" << boxedSize () << " )" << std::endl;
811+ r << std::string (indent + 1 , ' ' ) << " Marker: " << (int )((getInt8 (0 ) & 0b10000000 ) >> 7 ) << std::endl;
812+ r << std::string (indent + 1 , ' ' ) << " Version: " << (int )(getInt8 (0 ) & 0b01111111 ) << std::endl;
813+ r << std::string (indent + 1 , ' ' ) << " Profile: " << (int )((getInt8 (1 ) & 0b11100000 ) >> 5 ) << std::endl;
814+ r << std::string (indent + 1 , ' ' ) << " Level: " << (int )(getInt8 (1 ) & 0b00011111 ) << std::endl;
815+
816+ r << std::string (indent + 1 , ' ' ) << " Tier: " << (int )((getInt8 (2 ) & 0b10000000 ) >> 7 ) << std::endl;
817+
818+
819+ r << std::string (indent + 1 , ' ' ) << " Bit depth: " ;
820+ switch ((getInt8 (2 ) & 0b01100000 )){
821+ case 0b00000000 : r << " 8" ; break ;
822+ case 0b01000000 : r << " 10" ; break ;
823+ case 0b01100000 : r << " 12" ; break ;
824+ case 0b00100000 : r << " Unknown" ; break ;
825+ }
826+ r << std::endl;
827+
828+ r << std::string (indent + 1 , ' ' ) << " Subsampling format: " ;
829+ switch ((getInt8 (2 ) & 0b00011100 )){
830+ case 0b00000000 : r << " YUV 4:4:4" ; break ;
831+ case 0b00001000 : r << " YUV 4:2:2" ; break ;
832+ case 0b00001100 : r << " YUV 4:2:0" ; break ;
833+ case 0b00011100 : r << " Monochrome 4:0:0" ; break ;
834+ default : r << " Unknown" ;
835+ }
836+ r << std::endl;
837+
838+ r << std::string (indent + 1 , ' ' ) << " Subsampling position: " ;
839+ switch ((getInt8 (2 ) & 0b00000011 )){
840+ case 0 : r << " Unknown" ; break ;
841+ case 1 : r << " Vertical" ; break ;
842+ case 2 : r << " Co-located" ; break ;
843+ case 3 : r << " Reserved" ; break ;
844+ }
845+ r << std::endl;
846+
847+ if (getInt8 (3 ) & 0b00010000 ){
848+ r << std::string (indent + 1 , ' ' ) << " Initial presentation delay: " << (int )(getInt8 (3 ) & 0b00001111 ) + 1 << std::endl;
849+ }else {
850+ r << std::string (indent + 1 , ' ' ) << " Initial presentation delay: 0" << std::endl;
851+ }
852+
853+ r << std::string (indent + 1 , ' ' ) << (payloadSize () - 4 ) << " b of OBU initialization data" << std::endl;
854+
855+ return r.str ();
856+ }
857+
858+ void AV1C::setPayload (std::string newPayload){
859+ if (!reserve (0 , payloadSize (), newPayload.size ())){
860+ ERROR_MSG (" Cannot allocate enough memory for payload" );
861+ return ;
862+ }
863+ memcpy ((char *)payload (), (char *)newPayload.c_str (), newPayload.size ());
864+ }
865+
802866 Descriptor::Descriptor (){
803867 data = (char *)malloc (2 );
804868 data[0 ] = 0 ;
@@ -2692,22 +2756,26 @@ namespace MP4{
26922756 avccBox.setPayload (M.getInit (idx));
26932757 setCLAP (avccBox);
26942758 }
2695- /* LTS-START*/
26962759 if (tCodec == " HEVC" ){
26972760 setCodec (" hev1" );
26982761 MP4::HVCC hvccBox;
26992762 hvccBox.setPayload (M.getInit (idx));
27002763 setCLAP (hvccBox);
27012764 }
2702- /* LTS-END*/
2765+ if (tCodec == " AV1" ){
2766+ setCodec (" av01" );
2767+ MP4::AV1C av1cBox;
2768+ av1cBox.setPayload (M.getInit (idx));
2769+ setCLAP (av1cBox);
2770+ }
27032771 MP4::PASP paspBox;
27042772 setPASP (paspBox);
27052773 }
27062774
27072775 void VisualSampleEntry::initialize (){
27082776 memcpy (data + 4 , " erro" , 4 );
2709- setHorizResolution (0x00480000 );
2710- setVertResolution (0x00480000 );
2777+ setHorizResolution (72 );
2778+ setVertResolution (72 );
27112779 setFrameCount (1 );
27122780 setCompressorName (" " );
27132781 setDepth (0x0018 );
@@ -2726,17 +2794,17 @@ namespace MP4{
27262794
27272795 uint16_t VisualSampleEntry::getHeight (){return getInt16 (26 );}
27282796
2729- void VisualSampleEntry::setHorizResolution (uint32_t newHorizResolution){
2730- setInt32 (newHorizResolution, 28 );
2797+ void VisualSampleEntry::setHorizResolution (double newHorizResolution){
2798+ setInt32 (newHorizResolution * 65536.0 , 28 );
27312799 }
27322800
2733- uint32_t VisualSampleEntry::getHorizResolution (){return getInt32 (28 );}
2801+ double VisualSampleEntry::getHorizResolution (){return getInt32 (28 ) / 65536.0 ;}
27342802
2735- void VisualSampleEntry::setVertResolution (uint32_t newVertResolution){
2736- setInt32 (newVertResolution, 32 );
2803+ void VisualSampleEntry::setVertResolution (double newVertResolution){
2804+ setInt32 (newVertResolution * 65536.0 , 32 );
27372805 }
27382806
2739- uint32_t VisualSampleEntry::getVertResolution (){return getInt32 (32 );}
2807+ double VisualSampleEntry::getVertResolution (){return getInt32 (32 ) / 65536.0 ;}
27402808
27412809 void VisualSampleEntry::setFrameCount (uint16_t newFrameCount){setInt16 (newFrameCount, 40 );}
27422810
@@ -2839,8 +2907,8 @@ namespace MP4{
28392907 r << toPrettySampleString (indent);
28402908 r << std::string (indent + 1 , ' ' ) << " Width: " << getWidth () << std::endl;
28412909 r << std::string (indent + 1 , ' ' ) << " Height: " << getHeight () << std::endl;
2842- r << std::string (indent + 1 , ' ' ) << " HorizResolution: " << getHorizResolution () << std::endl;
2843- r << std::string (indent + 1 , ' ' ) << " VertResolution: " << getVertResolution () << std::endl;
2910+ r << std::string (indent + 1 , ' ' ) << " HorizResolution: " << getHorizResolution () << " DPI " << std::endl;
2911+ r << std::string (indent + 1 , ' ' ) << " VertResolution: " << getVertResolution () << " DPI " << std::endl;
28442912 r << std::string (indent + 1 , ' ' ) << " FrameCount: " << getFrameCount () << std::endl;
28452913 r << std::string (indent + 1 , ' ' ) << " CompressorName: " << getCompressorName () << std::endl;
28462914 r << std::string (indent + 1 , ' ' ) << " Depth: " << getDepth () << std::endl;
@@ -3249,6 +3317,12 @@ namespace MP4{
32493317 return toPrettyVisualString (indent, " [h264] H.264/MPEG-4 AVC" );
32503318 }
32513319
3320+ AV01::AV01 (){memcpy (data + 4 , " av01" , 4 );}
3321+
3322+ std::string AV01::toPrettyString (uint32_t indent){
3323+ return toPrettyVisualString (indent, " [av01] AV1 Video" );
3324+ }
3325+
32523326 FIEL::FIEL (){memcpy (data + 4 , " fiel" , 4 );}
32533327
32543328 void FIEL::setTotal (char newTotal){setInt8 (newTotal, 0 );}
0 commit comments