@@ -807,7 +807,6 @@ static avifBool avifImageSplitGrid(const avifImage * gridSplitImage, uint32_t gr
807
807
808
808
#define INVALID_QUALITY (-1)
809
809
#define DEFAULT_QUALITY 60 // Maps to a quantizer (QP) of 25.
810
- #define DEFAULT_QUALITY_ALPHA AVIF_QUALITY_LOSSLESS
811
810
#define DEFAULT_QUALITY_GAIN_MAP DEFAULT_QUALITY
812
811
#define PROGRESSIVE_WORST_QUALITY 10 // Not doing auto automatic layered encoding below this quality
813
812
#define PROGRESSIVE_START_QUALITY 2 // First layer use this quality
@@ -925,12 +924,6 @@ static avifBool avifEncodeRestOfImageSequence(avifEncoder * encoder,
925
924
while ((nextFile = avifInputGetFile (input , imageIndex )) != NULL ) {
926
925
uint64_t nextDurationInTimescales = nextFile -> duration ? nextFile -> duration : settings -> outputTiming .duration ;
927
926
928
- printf (" * Encoding frame %d [%" PRIu64 "/%" PRIu64 " ts]: %s\n" ,
929
- imageIndex ,
930
- nextDurationInTimescales ,
931
- settings -> outputTiming .timescale ,
932
- nextFile -> filename );
933
-
934
927
if (nextImage ) {
935
928
avifImageDestroy (nextImage );
936
929
}
@@ -969,6 +962,17 @@ static avifBool avifEncodeRestOfImageSequence(avifEncoder * encoder,
969
962
if (!avifEncodeUpdateEncoderSettings (encoder , nextSettings )) {
970
963
goto cleanup ;
971
964
}
965
+
966
+ printf (" * Encoding frame %d [%" PRIu64 "/%" PRIu64 " ts] color quality [%d (%s)], alpha quality [%d (%s)]: %s\n" ,
967
+ imageIndex ,
968
+ nextDurationInTimescales ,
969
+ settings -> outputTiming .timescale ,
970
+ encoder -> quality ,
971
+ qualityString (encoder -> quality ),
972
+ encoder -> qualityAlpha ,
973
+ qualityString (encoder -> qualityAlpha ),
974
+ nextFile -> filename );
975
+
972
976
const avifResult nextImageResult = avifEncoderAddImage (encoder , nextImage , nextDurationInTimescales , AVIF_ADD_IMAGE_FLAG_NONE );
973
977
if (nextImageResult != AVIF_RESULT_OK ) {
974
978
fprintf (stderr , "ERROR: Failed to encode image: %s\n" , avifResultToString (nextImageResult ));
@@ -1150,7 +1154,7 @@ static avifBool avifEncodeImagesFixedQuality(const avifSettings * settings,
1150
1154
}
1151
1155
#endif
1152
1156
1153
- printf ("Encoding with codec '%s' speed [%s], color quality [%d (%s)], alpha quality [%d (%s)]%s, %s, %d worker thread(s), please wait...\n" ,
1157
+ printf ("Encoding with initial settings: codec '%s' speed [%s], color quality [%d (%s)], alpha quality [%d (%s)]%s, %s, %d worker thread(s), please wait...\n" ,
1154
1158
codecName ? codecName : "none" ,
1155
1159
speedStr ,
1156
1160
encoder -> quality ,
@@ -1195,10 +1199,14 @@ static avifBool avifEncodeImagesFixedQuality(const avifSettings * settings,
1195
1199
1196
1200
uint64_t firstDurationInTimescales = firstFile -> duration ? firstFile -> duration : settings -> outputTiming .duration ;
1197
1201
if (input -> useStdin || (settings -> layers == 1 && input -> filesCount > 1 )) {
1198
- printf (" * Encoding frame %d [%" PRIu64 "/%" PRIu64 " ts]: %s\n" ,
1202
+ printf (" * Encoding frame %d [%" PRIu64 "/%" PRIu64 " ts] color quality [%d (%s)], alpha quality [%d (%s)] : %s\n" ,
1199
1203
0 ,
1200
1204
firstDurationInTimescales ,
1201
1205
settings -> outputTiming .timescale ,
1206
+ encoder -> quality ,
1207
+ qualityString (encoder -> quality ),
1208
+ encoder -> qualityAlpha ,
1209
+ qualityString (encoder -> qualityAlpha ),
1202
1210
firstFile -> filename );
1203
1211
}
1204
1212
const avifResult addImageResult = avifEncoderAddImage (encoder , firstImage , firstDurationInTimescales , addImageFlags );
@@ -1898,6 +1906,15 @@ int main(int argc, char * argv[])
1898
1906
++ argIndex ;
1899
1907
}
1900
1908
1909
+ // Alpha quality defaults to the same value as (color) quality until the first time it's explicitly set.
1910
+ for (int i = 0 ; i < input .filesCount ; ++ i ) {
1911
+ avifInputFileSettings * fileSettings = & input .files [i ].settings ;
1912
+ if (fileSettings -> qualityAlpha .set ) {
1913
+ break ;
1914
+ }
1915
+ fileSettings -> qualityAlpha = fileSettings -> quality ;
1916
+ }
1917
+
1901
1918
if (settings .jobs == -1 ) {
1902
1919
settings .jobs = avifQueryCPUCount ();
1903
1920
}
@@ -2146,7 +2163,7 @@ int main(int argc, char * argv[])
2146
2163
} else {
2147
2164
assert (!fileSettings -> maxQuantizerAlpha .set );
2148
2165
if (!fileSettings -> qualityAlpha .set ) {
2149
- fileSettings -> qualityAlpha = intSettingsEntryOf ( DEFAULT_QUALITY_ALPHA ) ;
2166
+ fileSettings -> qualityAlpha = fileSettings -> quality ;
2150
2167
}
2151
2168
fileSettings -> minQuantizerAlpha = intSettingsEntryOf (AVIF_QUANTIZER_BEST_QUALITY );
2152
2169
fileSettings -> maxQuantizerAlpha = intSettingsEntryOf (AVIF_QUANTIZER_WORST_QUALITY );
0 commit comments