Pass through starting sample index to codec when flushing with NthImage
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5c5da7f..d2dbf5a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@
### Changed
- Fixed bug in sync sample table element sizing
+- Pass through starting sample index to codec when flushing with NthImage
## [0.3.10] - 2019-09-26
### Added
diff --git a/include/avif/internal.h b/include/avif/internal.h
index 5185953..6ce2689 100644
--- a/include/avif/internal.h
+++ b/include/avif/internal.h
@@ -126,7 +126,7 @@
struct avifCodec;
struct avifCodecInternal;
-typedef avifBool (*avifCodecOpenFunc)(struct avifCodec * codec);
+typedef avifBool (*avifCodecOpenFunc)(struct avifCodec * codec, uint32_t firstSampleIndex);
// avifCodecAlphaLimitedRangeFunc: returns AVIF_TRUE if an alpha plane exists and was encoded with limited range
typedef avifBool (*avifCodecAlphaLimitedRangeFunc)(struct avifCodec * codec);
typedef avifBool (*avifCodecGetNextImageFunc)(struct avifCodec * codec, avifImage * image);
diff --git a/src/codec_aom.c b/src/codec_aom.c
index eb6a8fd..e72cea0 100644
--- a/src/codec_aom.c
+++ b/src/codec_aom.c
@@ -48,7 +48,7 @@
avifFree(codec->internal);
}
-static avifBool aomCodecOpen(struct avifCodec * codec)
+static avifBool aomCodecOpen(struct avifCodec * codec, uint32_t firstSampleIndex)
{
aom_codec_iface_t * decoder_interface = aom_codec_av1_dx();
if (aom_codec_dec_init(&codec->internal->decoder, decoder_interface, NULL, 0)) {
@@ -60,7 +60,7 @@
return AVIF_FALSE;
}
- codec->internal->inputSampleIndex = 0;
+ codec->internal->inputSampleIndex = firstSampleIndex;
codec->internal->iter = NULL;
return AVIF_TRUE;
}
diff --git a/src/codec_dav1d.c b/src/codec_dav1d.c
index 5d164d7..74f8920 100644
--- a/src/codec_dav1d.c
+++ b/src/codec_dav1d.c
@@ -57,7 +57,7 @@
return AVIF_TRUE;
}
-static avifBool dav1dCodecOpen(avifCodec * codec)
+static avifBool dav1dCodecOpen(avifCodec * codec, uint32_t firstSampleIndex)
{
if (codec->internal->dav1dContext == NULL) {
if (dav1d_open(&codec->internal->dav1dContext, &codec->internal->dav1dSettings) != 0) {
@@ -65,7 +65,7 @@
}
}
- codec->internal->inputSampleIndex = 0;
+ codec->internal->inputSampleIndex = firstSampleIndex;
return AVIF_TRUE;
}
diff --git a/src/read.c b/src/read.c
index 1dd0983..41a20e2 100644
--- a/src/read.c
+++ b/src/read.c
@@ -1250,13 +1250,13 @@
avifDataResetCodec(decoder->data);
decoder->data->codec[AVIF_CODEC_PLANES_COLOR] = avifCodecCreateForDecode(decoder->data->colorInput);
- if (!decoder->data->codec[AVIF_CODEC_PLANES_COLOR]->open(decoder->data->codec[AVIF_CODEC_PLANES_COLOR])) {
+ if (!decoder->data->codec[AVIF_CODEC_PLANES_COLOR]->open(decoder->data->codec[AVIF_CODEC_PLANES_COLOR], decoder->imageIndex + 1)) {
return AVIF_RESULT_DECODE_COLOR_FAILED;
}
if (decoder->data->alphaInput) {
decoder->data->codec[AVIF_CODEC_PLANES_ALPHA] = avifCodecCreateForDecode(decoder->data->alphaInput);
- if (!decoder->data->codec[AVIF_CODEC_PLANES_ALPHA]->open(decoder->data->codec[AVIF_CODEC_PLANES_ALPHA])) {
+ if (!decoder->data->codec[AVIF_CODEC_PLANES_ALPHA]->open(decoder->data->codec[AVIF_CODEC_PLANES_ALPHA], decoder->imageIndex + 1)) {
return AVIF_RESULT_DECODE_ALPHA_FAILED;
}
}