@@ -829,7 +829,6 @@ struct IMG_AnimationDecoderContext
829
829
830
830
int width ; /* Width of the animation */
831
831
int height ; /* Height of the animation */
832
- uint64_t timescale ; /* Timescale of the media (Hz) */
833
832
int repetitionCount ; /* Number of repetitions */
834
833
};
835
834
@@ -1052,7 +1051,7 @@ bool IMG_CreateAVIFAnimationDecoder(IMG_AnimationDecoder *decoder, SDL_Propertie
1052
1051
return false;
1053
1052
}
1054
1053
1055
- IMG_AnimationDecoderContext * ctx = (IMG_AnimationDecoderContext * )SDL_calloc (1 , sizeof (IMG_AnimationDecoderContext ));
1054
+ IMG_AnimationDecoderContext * ctx = (IMG_AnimationDecoderContext * )SDL_calloc (1 , sizeof (* ctx ));
1056
1055
if (!ctx ) {
1057
1056
return SDL_SetError ("Out of memory for AVIF decoder context" );
1058
1057
}
@@ -1119,7 +1118,6 @@ bool IMG_CreateAVIFAnimationDecoder(IMG_AnimationDecoder *decoder, SDL_Propertie
1119
1118
1120
1119
ctx -> width = ctx -> decoder -> image -> width ;
1121
1120
ctx -> height = ctx -> decoder -> image -> height ;
1122
- ctx -> timescale = ctx -> decoder -> timescale ;
1123
1121
ctx -> total_frames = ctx -> decoder -> imageCount ;
1124
1122
ctx -> repetitionCount = ctx -> decoder -> repetitionCount ;
1125
1123
@@ -1547,73 +1545,73 @@ bool IMG_CreateAVIFAnimationEncoder(IMG_AnimationEncoder *encoder, SDL_Propertie
1547
1545
return false;
1548
1546
}
1549
1547
1550
- encoder -> ctx = (IMG_AnimationEncoderContext * )SDL_calloc (1 , sizeof (IMG_AnimationEncoderContext ));
1551
- if (!encoder -> ctx ) {
1548
+ IMG_AnimationEncoderContext * ctx = (IMG_AnimationEncoderContext * )SDL_calloc (1 , sizeof (* ctx ));
1549
+ if (!ctx ) {
1552
1550
return SDL_SetError ("Out of memory for AVIF context" );
1553
1551
}
1554
1552
1555
- if (encoder -> quality < 0 )
1553
+ ctx -> encoder = lib .avifEncoderCreate ();
1554
+ if (!ctx -> encoder ) {
1555
+ SDL_free (ctx );
1556
+ return SDL_SetError ("Couldn't create AVIF encoder" );
1557
+ }
1558
+
1559
+ if (encoder -> quality < 0 ) {
1556
1560
encoder -> quality = 75 ;
1557
- else if (encoder -> quality > 100 )
1561
+ } else if (encoder -> quality > 100 ) {
1558
1562
encoder -> quality = 100 ;
1559
-
1560
- encoder -> ctx -> encoder = lib .avifEncoderCreate ();
1561
- if (!encoder -> ctx -> encoder ) {
1562
- SDL_free (encoder -> ctx );
1563
- encoder -> ctx = NULL ;
1564
- return SDL_SetError ("Couldn't create AVIF encoder" );
1565
1563
}
1566
1564
1567
1565
int availableLCores = SDL_GetNumLogicalCPUCores ();
1568
- int mThreads = (int )SDL_GetNumberProperty (props , "maxthreads" , availableLCores / 2 );
1569
- mThreads = SDL_clamp (mThreads , 1 , availableLCores );
1566
+ int threads = (int )SDL_GetNumberProperty (props , "maxthreads" , availableLCores / 2 );
1567
+ threads = SDL_clamp (threads , 1 , availableLCores );
1570
1568
1571
1569
int keyFrameInterval = (int )SDL_GetNumberProperty (props , "keyframeinterval" , 0 );
1572
1570
1573
- encoder -> ctx -> encoder -> maxThreads = mThreads ;
1574
- encoder -> ctx -> encoder -> quality = encoder -> quality ;
1571
+ ctx -> encoder -> maxThreads = threads ;
1572
+ ctx -> encoder -> quality = encoder -> quality ;
1575
1573
1576
- encoder -> ctx -> encoder -> qualityAlpha = AVIF_QUALITY_DEFAULT ;
1577
- encoder -> ctx -> encoder -> speed = AVIF_SPEED_FASTEST ;
1574
+ ctx -> encoder -> qualityAlpha = AVIF_QUALITY_DEFAULT ;
1575
+ ctx -> encoder -> speed = AVIF_SPEED_FASTEST ;
1578
1576
1579
- if (encoder -> ctx -> encoder -> quality >= 100 ) {
1580
- encoder -> ctx -> encoder -> keyframeInterval = SDL_min (1 , keyFrameInterval );
1581
- encoder -> ctx -> encoder -> minQuantizer = 0 ;
1582
- encoder -> ctx -> encoder -> maxQuantizer = 0 ;
1577
+ if (ctx -> encoder -> quality >= 100 ) {
1578
+ ctx -> encoder -> keyframeInterval = SDL_min (1 , keyFrameInterval );
1579
+ ctx -> encoder -> minQuantizer = 0 ;
1580
+ ctx -> encoder -> maxQuantizer = 0 ;
1583
1581
1584
- encoder -> ctx -> encoder -> minQuantizerAlpha = 0 ;
1585
- encoder -> ctx -> encoder -> maxQuantizerAlpha = 0 ;
1586
- encoder -> ctx -> encoder -> autoTiling = AVIF_FALSE ;
1582
+ ctx -> encoder -> minQuantizerAlpha = 0 ;
1583
+ ctx -> encoder -> maxQuantizerAlpha = 0 ;
1584
+ ctx -> encoder -> autoTiling = AVIF_FALSE ;
1587
1585
} else {
1588
- encoder -> ctx -> encoder -> keyframeInterval = keyFrameInterval ;
1589
- encoder -> ctx -> encoder -> minQuantizer = 8 ;
1590
- encoder -> ctx -> encoder -> maxQuantizer = 63 ;
1586
+ ctx -> encoder -> keyframeInterval = keyFrameInterval ;
1587
+ ctx -> encoder -> minQuantizer = 8 ;
1588
+ ctx -> encoder -> maxQuantizer = 63 ;
1591
1589
1592
- encoder -> ctx -> encoder -> minQuantizerAlpha = 0 ;
1593
- encoder -> ctx -> encoder -> maxQuantizerAlpha = 63 ;
1594
- encoder -> ctx -> encoder -> autoTiling = AVIF_TRUE ;
1590
+ ctx -> encoder -> minQuantizerAlpha = 0 ;
1591
+ ctx -> encoder -> maxQuantizerAlpha = 63 ;
1592
+ ctx -> encoder -> autoTiling = AVIF_TRUE ;
1595
1593
}
1596
1594
1597
- encoder -> ctx -> encoder -> tileRowsLog2 = 0 ;
1598
- encoder -> ctx -> encoder -> tileColsLog2 = 0 ;
1595
+ ctx -> encoder -> tileRowsLog2 = 0 ;
1596
+ ctx -> encoder -> tileColsLog2 = 0 ;
1599
1597
1600
- encoder -> ctx -> encoder -> timescale = ( uint32_t ) encoder -> timebase_denominator ;
1598
+ ctx -> encoder -> timescale = encoder -> timebase_denominator ;
1601
1599
1602
1600
bool ignoreProps = SDL_GetBooleanProperty (props , IMG_PROP_METADATA_IGNORE_PROPS_BOOLEAN , false);
1603
1601
if (!ignoreProps ) {
1604
- encoder -> ctx -> encoder -> repetitionCount = (int )SDL_GetNumberProperty (props , IMG_PROP_METADATA_LOOP_COUNT_NUMBER , -1 );
1605
- if (encoder -> ctx -> encoder -> repetitionCount < 1 && encoder -> ctx -> encoder -> repetitionCount != -1 ) {
1606
- encoder -> ctx -> encoder -> repetitionCount = -1 ;
1602
+ ctx -> encoder -> repetitionCount = (int )SDL_GetNumberProperty (props , IMG_PROP_METADATA_LOOP_COUNT_NUMBER , -1 );
1603
+ if (ctx -> encoder -> repetitionCount < 1 && ctx -> encoder -> repetitionCount != -1 ) {
1604
+ ctx -> encoder -> repetitionCount = -1 ;
1607
1605
}
1608
1606
1609
- encoder -> ctx -> desc = SDL_GetStringProperty (props , IMG_PROP_METADATA_DESCRIPTION_STRING , NULL );
1610
- encoder -> ctx -> rights = SDL_GetStringProperty (props , IMG_PROP_METADATA_COPYRIGHT_STRING , NULL );
1611
- encoder -> ctx -> title = SDL_GetStringProperty (props , IMG_PROP_METADATA_TITLE_STRING , NULL );
1612
- encoder -> ctx -> creator = SDL_GetStringProperty (props , IMG_PROP_METADATA_AUTHOR_STRING , NULL );
1613
- encoder -> ctx -> createdate = SDL_GetStringProperty (props , IMG_PROP_METADATA_CREATION_TIME_STRING , NULL );
1607
+ ctx -> desc = SDL_GetStringProperty (props , IMG_PROP_METADATA_DESCRIPTION_STRING , NULL );
1608
+ ctx -> rights = SDL_GetStringProperty (props , IMG_PROP_METADATA_COPYRIGHT_STRING , NULL );
1609
+ ctx -> title = SDL_GetStringProperty (props , IMG_PROP_METADATA_TITLE_STRING , NULL );
1610
+ ctx -> creator = SDL_GetStringProperty (props , IMG_PROP_METADATA_AUTHOR_STRING , NULL );
1611
+ ctx -> createdate = SDL_GetStringProperty (props , IMG_PROP_METADATA_CREATION_TIME_STRING , NULL );
1614
1612
}
1615
1613
1616
- encoder -> ctx -> first_frame_added = false ;
1614
+ encoder -> ctx = ctx ;
1617
1615
encoder -> AddFrame = AnimationEncoder_AddFrame ;
1618
1616
encoder -> Close = AnimationEncoder_End ;
1619
1617
0 commit comments