[FFmpeg-devel,2/2] avcodec/tiff: Multi-page support

Submitted by velocityra@gmail.com on March 22, 2019, 2:50 p.m.

Details

Message ID 20190322145049.25432-2-velocityra@gmail.com
State New
Headers show

Commit Message

velocityra@gmail.com March 22, 2019, 2:50 p.m.
From: Nick Renieris <velocityra@gmail.com>

Option "-page N" (page index N starts from 1) can now be used to specify which TIFF page/subfile to decode.

Signed-off-by: Nick Renieris <velocityra@gmail.com>
---
 libavcodec/tiff.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

Comments

Carl Eugen Hoyos March 22, 2019, 10:13 p.m.
2019-03-22 15:50 GMT+01:00, velocityra@gmail.com <velocityra@gmail.com>:
> From: Nick Renieris <velocityra@gmail.com>
>
> Option "-page N" (page index N starts from 1) can now
> be used to specify which TIFF page/subfile to decode.

What is the current behaviour?
Shouldn't the decoder output all pages as for a video file?

Carl Eugen
velocityra@gmail.com March 23, 2019, 3:29 a.m.
Στις Παρ, 22 Μαρ 2019 στις 6:35 μ.μ., ο/η Moritz Barsnick
<barsnick@gmx.net> έγραψε:
> I was about to write "could you please also update the documentation",
> but just realized that the tiff encoder isn't documented. :-P

Hahah. I can solve that in a later patch :)

Στις Σάβ, 23 Μαρ 2019 στις 12:13 π.μ., ο/η Carl Eugen Hoyos
<ceffmpeg@gmail.com> έγραψε:
> What is the current behaviour?
> Shouldn't the decoder output all pages as for a video file?

I was told by Paul to do it this way (select based on an option).
I'm assuming it's non-trivial to output all pages given the current
architecture, perhaps Paul can elaborate.
Paul B Mahol March 23, 2019, 8:11 a.m.
On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com <velocityra@gmail.com>:
>> From: Nick Renieris <velocityra@gmail.com>
>>
>> Option "-page N" (page index N starts from 1) can now
>> be used to specify which TIFF page/subfile to decode.
>
> What is the current behaviour?
> Shouldn't the decoder output all pages as for a video file?

How?

>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Carl Eugen Hoyos March 23, 2019, 12:33 p.m.
2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com <velocityra@gmail.com>:
>>> From: Nick Renieris <velocityra@gmail.com>
>>>
>>> Option "-page N" (page index N starts from 1) can now
>>> be used to specify which TIFF page/subfile to decode.
>>
>> What is the current behaviour?
>> Shouldn't the decoder output all pages as for a video file?
>
> How?

I would have suggested decoder flush.

Carl Eugen
Paul B Mahol March 23, 2019, 12:34 p.m.
On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com <velocityra@gmail.com>:
>>>> From: Nick Renieris <velocityra@gmail.com>
>>>>
>>>> Option "-page N" (page index N starts from 1) can now
>>>> be used to specify which TIFF page/subfile to decode.
>>>
>>> What is the current behaviour?
>>> Shouldn't the decoder output all pages as for a video file?
>>
>> How?
>
> I would have suggested decoder flush.
>

What? Can you elaborate what you think?
Carl Eugen Hoyos March 23, 2019, 12:54 p.m.
2019-03-23 13:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com <velocityra@gmail.com>:
>>>>> From: Nick Renieris <velocityra@gmail.com>
>>>>>
>>>>> Option "-page N" (page index N starts from 1) can now
>>>>> be used to specify which TIFF page/subfile to decode.
>>>>
>>>> What is the current behaviour?
>>>> Shouldn't the decoder output all pages as for a video file?
>>>
>>> How?
>>
>> I would have suggested decoder flush.

The word is probably "drain".

> What? Can you elaborate what you think?

Isn't there a return value that leads to subsequent calls of
AVCodec->decode()?

Carl Eugen
velocityra@gmail.com March 28, 2019, 10:52 a.m.
Any news on this? Is there something I should do?

Στις Σάβ, 23 Μαρ 2019 στις 2:54 μ.μ., ο/η Carl Eugen Hoyos
<ceffmpeg@gmail.com> έγραψε:
>
> 2019-03-23 13:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> > On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> >>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com <velocityra@gmail.com>:
> >>>>> From: Nick Renieris <velocityra@gmail.com>
> >>>>>
> >>>>> Option "-page N" (page index N starts from 1) can now
> >>>>> be used to specify which TIFF page/subfile to decode.
> >>>>
> >>>> What is the current behaviour?
> >>>> Shouldn't the decoder output all pages as for a video file?
> >>>
> >>> How?
> >>
> >> I would have suggested decoder flush.
>
> The word is probably "drain".
>
> > What? Can you elaborate what you think?
>
> Isn't there a return value that leads to subsequent calls of
> AVCodec->decode()?
>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Paul B Mahol March 28, 2019, 11:03 a.m.
On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
> Any news on this? Is there something I should do?

Have you uploaded small tiff so this patch can be tested?

>
> Στις Σάβ, 23 Μαρ 2019 στις 2:54 μ.μ., ο/η Carl Eugen Hoyos
> <ceffmpeg@gmail.com> έγραψε:
>>
>> 2019-03-23 13:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>> > On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> >> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>> >>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> >>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com
>> >>>> <velocityra@gmail.com>:
>> >>>>> From: Nick Renieris <velocityra@gmail.com>
>> >>>>>
>> >>>>> Option "-page N" (page index N starts from 1) can now
>> >>>>> be used to specify which TIFF page/subfile to decode.
>> >>>>
>> >>>> What is the current behaviour?
>> >>>> Shouldn't the decoder output all pages as for a video file?
>> >>>
>> >>> How?
>> >>
>> >> I would have suggested decoder flush.
>>
>> The word is probably "drain".
>>
>> > What? Can you elaborate what you think?
>>
>> Isn't there a return value that leads to subsequent calls of
>> AVCodec->decode()?
>>
>> Carl Eugen
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
velocityra@gmail.com March 28, 2019, 12:58 p.m.
I haven't, is there a specific place that it's preferred I upload it to?

Στις Πέμ, 28 Μαρ 2019 στις 1:12 μ.μ., ο/η Paul B Mahol
<onemda@gmail.com> έγραψε:
>
> On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
> > Any news on this? Is there something I should do?
>
> Have you uploaded small tiff so this patch can be tested?
>
> >
> > Στις Σάβ, 23 Μαρ 2019 στις 2:54 μ.μ., ο/η Carl Eugen Hoyos
> > <ceffmpeg@gmail.com> έγραψε:
> >>
> >> 2019-03-23 13:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> >> > On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >> >> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> >> >>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >> >>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com
> >> >>>> <velocityra@gmail.com>:
> >> >>>>> From: Nick Renieris <velocityra@gmail.com>
> >> >>>>>
> >> >>>>> Option "-page N" (page index N starts from 1) can now
> >> >>>>> be used to specify which TIFF page/subfile to decode.
> >> >>>>
> >> >>>> What is the current behaviour?
> >> >>>> Shouldn't the decoder output all pages as for a video file?
> >> >>>
> >> >>> How?
> >> >>
> >> >> I would have suggested decoder flush.
> >>
> >> The word is probably "drain".
> >>
> >> > What? Can you elaborate what you think?
> >>
> >> Isn't there a return value that leads to subsequent calls of
> >> AVCodec->decode()?
> >>
> >> Carl Eugen
> >> _______________________________________________
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
velocityra@gmail.com March 28, 2019, 1:02 p.m.
When I made the patch I did ask you on IRC whether I should upload
something and got no answer.

Στις Πέμ, 28 Μαρ 2019 στις 2:58 μ.μ., ο/η Nick Renieris
<velocityra@gmail.com> έγραψε:
>
> I haven't, is there a specific place that it's preferred I upload it to?
>
> Στις Πέμ, 28 Μαρ 2019 στις 1:12 μ.μ., ο/η Paul B Mahol
> <onemda@gmail.com> έγραψε:
> >
> > On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
> > > Any news on this? Is there something I should do?
> >
> > Have you uploaded small tiff so this patch can be tested?
> >
> > >
> > > Στις Σάβ, 23 Μαρ 2019 στις 2:54 μ.μ., ο/η Carl Eugen Hoyos
> > > <ceffmpeg@gmail.com> έγραψε:
> > >>
> > >> 2019-03-23 13:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> > >> > On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> > >> >> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> > >> >>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> > >> >>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com
> > >> >>>> <velocityra@gmail.com>:
> > >> >>>>> From: Nick Renieris <velocityra@gmail.com>
> > >> >>>>>
> > >> >>>>> Option "-page N" (page index N starts from 1) can now
> > >> >>>>> be used to specify which TIFF page/subfile to decode.
> > >> >>>>
> > >> >>>> What is the current behaviour?
> > >> >>>> Shouldn't the decoder output all pages as for a video file?
> > >> >>>
> > >> >>> How?
> > >> >>
> > >> >> I would have suggested decoder flush.
> > >>
> > >> The word is probably "drain".
> > >>
> > >> > What? Can you elaborate what you think?
> > >>
> > >> Isn't there a return value that leads to subsequent calls of
> > >> AVCodec->decode()?
> > >>
> > >> Carl Eugen
> > >> _______________________________________________
> > >> ffmpeg-devel mailing list
> > >> ffmpeg-devel@ffmpeg.org
> > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >>
> > >> To unsubscribe, visit link above, or email
> > >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > > _______________________________________________
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> > > To unsubscribe, visit link above, or email
> > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Paul B Mahol March 28, 2019, 2:35 p.m.
On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
> When I made the patch I did ask you on IRC whether I should upload
> something and got no answer.
>

Please upload it, somewhere like https://0x0.st/

> Στις Πέμ, 28 Μαρ 2019 στις 2:58 μ.μ., ο/η Nick Renieris
> <velocityra@gmail.com> έγραψε:
>>
>> I haven't, is there a specific place that it's preferred I upload it to?
>>
>> Στις Πέμ, 28 Μαρ 2019 στις 1:12 μ.μ., ο/η Paul B Mahol
>> <onemda@gmail.com> έγραψε:
>> >
>> > On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
>> > > Any news on this? Is there something I should do?
>> >
>> > Have you uploaded small tiff so this patch can be tested?
>> >
>> > >
>> > > Στις Σάβ, 23 Μαρ 2019 στις 2:54 μ.μ., ο/η Carl Eugen Hoyos
>> > > <ceffmpeg@gmail.com> έγραψε:
>> > >>
>> > >> 2019-03-23 13:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>> > >> > On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> > >> >> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>> > >> >>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> > >> >>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com
>> > >> >>>> <velocityra@gmail.com>:
>> > >> >>>>> From: Nick Renieris <velocityra@gmail.com>
>> > >> >>>>>
>> > >> >>>>> Option "-page N" (page index N starts from 1) can now
>> > >> >>>>> be used to specify which TIFF page/subfile to decode.
>> > >> >>>>
>> > >> >>>> What is the current behaviour?
>> > >> >>>> Shouldn't the decoder output all pages as for a video file?
>> > >> >>>
>> > >> >>> How?
>> > >> >>
>> > >> >> I would have suggested decoder flush.
>> > >>
>> > >> The word is probably "drain".
>> > >>
>> > >> > What? Can you elaborate what you think?
>> > >>
>> > >> Isn't there a return value that leads to subsequent calls of
>> > >> AVCodec->decode()?
>> > >>
>> > >> Carl Eugen
>> > >> _______________________________________________
>> > >> ffmpeg-devel mailing list
>> > >> ffmpeg-devel@ffmpeg.org
>> > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> > >>
>> > >> To unsubscribe, visit link above, or email
>> > >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> > > _______________________________________________
>> > > ffmpeg-devel mailing list
>> > > ffmpeg-devel@ffmpeg.org
>> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> > >
>> > > To unsubscribe, visit link above, or email
>> > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> > _______________________________________________
>> > ffmpeg-devel mailing list
>> > ffmpeg-devel@ffmpeg.org
>> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >
>> > To unsubscribe, visit link above, or email
>> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
velocityra@gmail.com March 28, 2019, 4:03 p.m.
Ok, here's a multipage tif with 3 pages, the two first are blue and
the last one red:
https://0x0.st/zKdB.tif

Στις Πέμ, 28 Μαρ 2019 στις 4:35 μ.μ., ο/η Paul B Mahol
<onemda@gmail.com> έγραψε:
>
> On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
> > When I made the patch I did ask you on IRC whether I should upload
> > something and got no answer.
> >
>
> Please upload it, somewhere like https://0x0.st/
>
> > Στις Πέμ, 28 Μαρ 2019 στις 2:58 μ.μ., ο/η Nick Renieris
> > <velocityra@gmail.com> έγραψε:
> >>
> >> I haven't, is there a specific place that it's preferred I upload it to?
> >>
> >> Στις Πέμ, 28 Μαρ 2019 στις 1:12 μ.μ., ο/η Paul B Mahol
> >> <onemda@gmail.com> έγραψε:
> >> >
> >> > On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
> >> > > Any news on this? Is there something I should do?
> >> >
> >> > Have you uploaded small tiff so this patch can be tested?
> >> >
> >> > >
> >> > > Στις Σάβ, 23 Μαρ 2019 στις 2:54 μ.μ., ο/η Carl Eugen Hoyos
> >> > > <ceffmpeg@gmail.com> έγραψε:
> >> > >>
> >> > >> 2019-03-23 13:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> >> > >> > On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >> > >> >> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> >> > >> >>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >> > >> >>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com
> >> > >> >>>> <velocityra@gmail.com>:
> >> > >> >>>>> From: Nick Renieris <velocityra@gmail.com>
> >> > >> >>>>>
> >> > >> >>>>> Option "-page N" (page index N starts from 1) can now
> >> > >> >>>>> be used to specify which TIFF page/subfile to decode.
> >> > >> >>>>
> >> > >> >>>> What is the current behaviour?
> >> > >> >>>> Shouldn't the decoder output all pages as for a video file?
> >> > >> >>>
> >> > >> >>> How?
> >> > >> >>
> >> > >> >> I would have suggested decoder flush.
> >> > >>
> >> > >> The word is probably "drain".
> >> > >>
> >> > >> > What? Can you elaborate what you think?
> >> > >>
> >> > >> Isn't there a return value that leads to subsequent calls of
> >> > >> AVCodec->decode()?
> >> > >>
> >> > >> Carl Eugen
> >> > >> _______________________________________________
> >> > >> ffmpeg-devel mailing list
> >> > >> ffmpeg-devel@ffmpeg.org
> >> > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >> > >>
> >> > >> To unsubscribe, visit link above, or email
> >> > >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >> > > _______________________________________________
> >> > > ffmpeg-devel mailing list
> >> > > ffmpeg-devel@ffmpeg.org
> >> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >> > >
> >> > > To unsubscribe, visit link above, or email
> >> > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >> > _______________________________________________
> >> > ffmpeg-devel mailing list
> >> > ffmpeg-devel@ffmpeg.org
> >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >> >
> >> > To unsubscribe, visit link above, or email
> >> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Paul B Mahol March 28, 2019, 10:51 p.m.
On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
> Ok, here's a multipage tif with 3 pages, the two first are blue and
> the last one red:
> https://0x0.st/zKdB.tif
>

Patch contains UINT16 opt and as is can not be applied.
Please fix that.

> Στις Πέμ, 28 Μαρ 2019 στις 4:35 μ.μ., ο/η Paul B Mahol
> <onemda@gmail.com> έγραψε:
>>
>> On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
>> > When I made the patch I did ask you on IRC whether I should upload
>> > something and got no answer.
>> >
>>
>> Please upload it, somewhere like https://0x0.st/
>>
>> > Στις Πέμ, 28 Μαρ 2019 στις 2:58 μ.μ., ο/η Nick Renieris
>> > <velocityra@gmail.com> έγραψε:
>> >>
>> >> I haven't, is there a specific place that it's preferred I upload it
>> >> to?
>> >>
>> >> Στις Πέμ, 28 Μαρ 2019 στις 1:12 μ.μ., ο/η Paul B Mahol
>> >> <onemda@gmail.com> έγραψε:
>> >> >
>> >> > On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
>> >> > > Any news on this? Is there something I should do?
>> >> >
>> >> > Have you uploaded small tiff so this patch can be tested?
>> >> >
>> >> > >
>> >> > > Στις Σάβ, 23 Μαρ 2019 στις 2:54 μ.μ., ο/η Carl Eugen Hoyos
>> >> > > <ceffmpeg@gmail.com> έγραψε:
>> >> > >>
>> >> > >> 2019-03-23 13:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>> >> > >> > On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> >> > >> >> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>> >> > >> >>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> >> > >> >>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com
>> >> > >> >>>> <velocityra@gmail.com>:
>> >> > >> >>>>> From: Nick Renieris <velocityra@gmail.com>
>> >> > >> >>>>>
>> >> > >> >>>>> Option "-page N" (page index N starts from 1) can now
>> >> > >> >>>>> be used to specify which TIFF page/subfile to decode.
>> >> > >> >>>>
>> >> > >> >>>> What is the current behaviour?
>> >> > >> >>>> Shouldn't the decoder output all pages as for a video file?
>> >> > >> >>>
>> >> > >> >>> How?
>> >> > >> >>
>> >> > >> >> I would have suggested decoder flush.
>> >> > >>
>> >> > >> The word is probably "drain".
>> >> > >>
>> >> > >> > What? Can you elaborate what you think?
>> >> > >>
>> >> > >> Isn't there a return value that leads to subsequent calls of
>> >> > >> AVCodec->decode()?
>> >> > >>
>> >> > >> Carl Eugen
>> >> > >> _______________________________________________
>> >> > >> ffmpeg-devel mailing list
>> >> > >> ffmpeg-devel@ffmpeg.org
>> >> > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >> > >>
>> >> > >> To unsubscribe, visit link above, or email
>> >> > >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> >> > > _______________________________________________
>> >> > > ffmpeg-devel mailing list
>> >> > > ffmpeg-devel@ffmpeg.org
>> >> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >> > >
>> >> > > To unsubscribe, visit link above, or email
>> >> > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> >> > _______________________________________________
>> >> > ffmpeg-devel mailing list
>> >> > ffmpeg-devel@ffmpeg.org
>> >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >> >
>> >> > To unsubscribe, visit link above, or email
>> >> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> > _______________________________________________
>> > ffmpeg-devel mailing list
>> > ffmpeg-devel@ffmpeg.org
>> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >
>> > To unsubscribe, visit link above, or email
>> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
velocityra@gmail.com March 29, 2019, 6:39 a.m.
Huh? No I fixed that, it's AV_OPT_TYPE_INT now.
See the second email in this list (first was the initial patch, then
the corrected patch).

Στις Παρ, 29 Μαρ 2019 στις 12:51 π.μ., ο/η Paul B Mahol
<onemda@gmail.com> έγραψε:
>
> On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
> > Ok, here's a multipage tif with 3 pages, the two first are blue and
> > the last one red:
> > https://0x0.st/zKdB.tif
> >
>
> Patch contains UINT16 opt and as is can not be applied.
> Please fix that.
>
> > Στις Πέμ, 28 Μαρ 2019 στις 4:35 μ.μ., ο/η Paul B Mahol
> > <onemda@gmail.com> έγραψε:
> >>
> >> On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
> >> > When I made the patch I did ask you on IRC whether I should upload
> >> > something and got no answer.
> >> >
> >>
> >> Please upload it, somewhere like https://0x0.st/
> >>
> >> > Στις Πέμ, 28 Μαρ 2019 στις 2:58 μ.μ., ο/η Nick Renieris
> >> > <velocityra@gmail.com> έγραψε:
> >> >>
> >> >> I haven't, is there a specific place that it's preferred I upload it
> >> >> to?
> >> >>
> >> >> Στις Πέμ, 28 Μαρ 2019 στις 1:12 μ.μ., ο/η Paul B Mahol
> >> >> <onemda@gmail.com> έγραψε:
> >> >> >
> >> >> > On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
> >> >> > > Any news on this? Is there something I should do?
> >> >> >
> >> >> > Have you uploaded small tiff so this patch can be tested?
> >> >> >
> >> >> > >
> >> >> > > Στις Σάβ, 23 Μαρ 2019 στις 2:54 μ.μ., ο/η Carl Eugen Hoyos
> >> >> > > <ceffmpeg@gmail.com> έγραψε:
> >> >> > >>
> >> >> > >> 2019-03-23 13:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> >> >> > >> > On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >> >> > >> >> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
> >> >> > >> >>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >> >> > >> >>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com
> >> >> > >> >>>> <velocityra@gmail.com>:
> >> >> > >> >>>>> From: Nick Renieris <velocityra@gmail.com>
> >> >> > >> >>>>>
> >> >> > >> >>>>> Option "-page N" (page index N starts from 1) can now
> >> >> > >> >>>>> be used to specify which TIFF page/subfile to decode.
> >> >> > >> >>>>
> >> >> > >> >>>> What is the current behaviour?
> >> >> > >> >>>> Shouldn't the decoder output all pages as for a video file?
> >> >> > >> >>>
> >> >> > >> >>> How?
> >> >> > >> >>
> >> >> > >> >> I would have suggested decoder flush.
> >> >> > >>
> >> >> > >> The word is probably "drain".
> >> >> > >>
> >> >> > >> > What? Can you elaborate what you think?
> >> >> > >>
> >> >> > >> Isn't there a return value that leads to subsequent calls of
> >> >> > >> AVCodec->decode()?
> >> >> > >>
> >> >> > >> Carl Eugen
> >> >> > >> _______________________________________________
> >> >> > >> ffmpeg-devel mailing list
> >> >> > >> ffmpeg-devel@ffmpeg.org
> >> >> > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >> >> > >>
> >> >> > >> To unsubscribe, visit link above, or email
> >> >> > >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >> >> > > _______________________________________________
> >> >> > > ffmpeg-devel mailing list
> >> >> > > ffmpeg-devel@ffmpeg.org
> >> >> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >> >> > >
> >> >> > > To unsubscribe, visit link above, or email
> >> >> > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >> >> > _______________________________________________
> >> >> > ffmpeg-devel mailing list
> >> >> > ffmpeg-devel@ffmpeg.org
> >> >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >> >> >
> >> >> > To unsubscribe, visit link above, or email
> >> >> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >> > _______________________________________________
> >> > ffmpeg-devel mailing list
> >> > ffmpeg-devel@ffmpeg.org
> >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >> >
> >> > To unsubscribe, visit link above, or email
> >> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >> _______________________________________________
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Paul B Mahol March 29, 2019, 9:05 a.m.
On 3/29/19, Nick Renieris <velocityra@gmail.com> wrote:
> Huh? No I fixed that, it's AV_OPT_TYPE_INT now.
> See the second email in this list (first was the initial patch, then
> the corrected patch).
>

You should also check max number of available pages.
And issue warning if user requested more than available and than provide some
page.

> Στις Παρ, 29 Μαρ 2019 στις 12:51 π.μ., ο/η Paul B Mahol
> <onemda@gmail.com> έγραψε:
>>
>> On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
>> > Ok, here's a multipage tif with 3 pages, the two first are blue and
>> > the last one red:
>> > https://0x0.st/zKdB.tif
>> >
>>
>> Patch contains UINT16 opt and as is can not be applied.
>> Please fix that.
>>
>> > Στις Πέμ, 28 Μαρ 2019 στις 4:35 μ.μ., ο/η Paul B Mahol
>> > <onemda@gmail.com> έγραψε:
>> >>
>> >> On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
>> >> > When I made the patch I did ask you on IRC whether I should upload
>> >> > something and got no answer.
>> >> >
>> >>
>> >> Please upload it, somewhere like https://0x0.st/
>> >>
>> >> > Στις Πέμ, 28 Μαρ 2019 στις 2:58 μ.μ., ο/η Nick Renieris
>> >> > <velocityra@gmail.com> έγραψε:
>> >> >>
>> >> >> I haven't, is there a specific place that it's preferred I upload it
>> >> >> to?
>> >> >>
>> >> >> Στις Πέμ, 28 Μαρ 2019 στις 1:12 μ.μ., ο/η Paul B Mahol
>> >> >> <onemda@gmail.com> έγραψε:
>> >> >> >
>> >> >> > On 3/28/19, Nick Renieris <velocityra@gmail.com> wrote:
>> >> >> > > Any news on this? Is there something I should do?
>> >> >> >
>> >> >> > Have you uploaded small tiff so this patch can be tested?
>> >> >> >
>> >> >> > >
>> >> >> > > Στις Σάβ, 23 Μαρ 2019 στις 2:54 μ.μ., ο/η Carl Eugen Hoyos
>> >> >> > > <ceffmpeg@gmail.com> έγραψε:
>> >> >> > >>
>> >> >> > >> 2019-03-23 13:34 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>> >> >> > >> > On 3/23/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> >> >> > >> >> 2019-03-23 9:11 GMT+01:00, Paul B Mahol <onemda@gmail.com>:
>> >> >> > >> >>> On 3/22/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> >> >> > >> >>>> 2019-03-22 15:50 GMT+01:00, velocityra@gmail.com
>> >> >> > >> >>>> <velocityra@gmail.com>:
>> >> >> > >> >>>>> From: Nick Renieris <velocityra@gmail.com>
>> >> >> > >> >>>>>
>> >> >> > >> >>>>> Option "-page N" (page index N starts from 1) can now
>> >> >> > >> >>>>> be used to specify which TIFF page/subfile to decode.
>> >> >> > >> >>>>
>> >> >> > >> >>>> What is the current behaviour?
>> >> >> > >> >>>> Shouldn't the decoder output all pages as for a video
>> >> >> > >> >>>> file?
>> >> >> > >> >>>
>> >> >> > >> >>> How?
>> >> >> > >> >>
>> >> >> > >> >> I would have suggested decoder flush.
>> >> >> > >>
>> >> >> > >> The word is probably "drain".
>> >> >> > >>
>> >> >> > >> > What? Can you elaborate what you think?
>> >> >> > >>
>> >> >> > >> Isn't there a return value that leads to subsequent calls of
>> >> >> > >> AVCodec->decode()?
>> >> >> > >>
>> >> >> > >> Carl Eugen
>> >> >> > >> _______________________________________________
>> >> >> > >> ffmpeg-devel mailing list
>> >> >> > >> ffmpeg-devel@ffmpeg.org
>> >> >> > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >> >> > >>
>> >> >> > >> To unsubscribe, visit link above, or email
>> >> >> > >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> >> >> > > _______________________________________________
>> >> >> > > ffmpeg-devel mailing list
>> >> >> > > ffmpeg-devel@ffmpeg.org
>> >> >> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >> >> > >
>> >> >> > > To unsubscribe, visit link above, or email
>> >> >> > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> >> >> > _______________________________________________
>> >> >> > ffmpeg-devel mailing list
>> >> >> > ffmpeg-devel@ffmpeg.org
>> >> >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >> >> >
>> >> >> > To unsubscribe, visit link above, or email
>> >> >> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> >> > _______________________________________________
>> >> > ffmpeg-devel mailing list
>> >> > ffmpeg-devel@ffmpeg.org
>> >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >> >
>> >> > To unsubscribe, visit link above, or email
>> >> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> >> _______________________________________________
>> >> ffmpeg-devel mailing list
>> >> ffmpeg-devel@ffmpeg.org
>> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >>
>> >> To unsubscribe, visit link above, or email
>> >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> > _______________________________________________
>> > ffmpeg-devel mailing list
>> > ffmpeg-devel@ffmpeg.org
>> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >
>> > To unsubscribe, visit link above, or email
>> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
velocityra@gmail.com March 29, 2019, 9:14 a.m.
Στις Παρ, 29 Μαρ 2019 στις 11:05 π.μ., ο/η Paul B Mahol
<onemda@gmail.com> έγραψε:
> You should also check max number of available pages.
> And issue warning if user requested more than available and than provide some
> page.

Yeah, I _would_ have done that, but the images I've seen don't
actually contain the max number of pages in PageNumber[1].
Instead, they seem to contain PageNumber[0] + 1.
Here's an example from the file I sent (generated with IrfanView):
https://i.imgur.com/CEWADrD.png
The PageNumber tag from the last IFD couldn't fit in the screenshot,
it's PageNumber[0] = 2 and PageNumber[1] = 3.
Paul B Mahol March 30, 2019, 12:28 p.m.
On 3/29/19, Nick Renieris <velocityra@gmail.com> wrote:
> Στις Παρ, 29 Μαρ 2019 στις 11:05 π.μ., ο/η Paul B Mahol
> <onemda@gmail.com> έγραψε:
>> You should also check max number of available pages.
>> And issue warning if user requested more than available and than provide
>> some
>> page.
>
> Yeah, I _would_ have done that, but the images I've seen don't
> actually contain the max number of pages in PageNumber[1].
> Instead, they seem to contain PageNumber[0] + 1.
> Here's an example from the file I sent (generated with IrfanView):
> https://i.imgur.com/CEWADrD.png
> The PageNumber tag from the last IFD couldn't fit in the screenshot,
> it's PageNumber[0] = 2 and PageNumber[1] = 3.

OK, will apply soon.

Patch hide | download patch | download mbox

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 29a80a6892..94ff4bd394 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -55,6 +55,7 @@  typedef struct TiffContext {
     GetByteContext gb;
 
     int get_subimage;
+    uint16_t get_page;
 
     int width, height;
     unsigned int bpp, bppcount;
@@ -75,6 +76,7 @@  typedef struct TiffContext {
     unsigned white_level;
 
     uint32_t sub_ifd;
+    uint16_t cur_page;
 
     int strips, rps, sstype;
     int sot;
@@ -1322,6 +1324,12 @@  static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
         break;
     case TIFF_PAGE_NUMBER:
         ADD_METADATA(count, "page_number", " / ");
+        // need to seek back to re-read the page number
+        bytestream2_seek(&s->gb, -count * sizeof(uint16_t), SEEK_CUR);
+        // read the page number
+        s->cur_page = ff_tget(&s->gb, TIFF_SHORT, s->le);
+        // get back to where we were before the previous seek
+        bytestream2_seek(&s->gb, count * sizeof(uint16_t) - sizeof(uint16_t), SEEK_CUR);
         break;
     case TIFF_SOFTWARE_NAME:
         ADD_METADATA(count, "software", NULL);
@@ -1359,6 +1367,7 @@  static int decode_frame(AVCodecContext *avctx,
     uint8_t *dst;
     GetByteContext stripsizes;
     GetByteContext stripdata;
+    int retry_for_subifd, retry_for_page;
 
     bytestream2_init(&s->gb, avpkt->data, avpkt->size);
 
@@ -1379,6 +1388,7 @@  again:
     s->fill_order  = 0;
     s->white_level = 0;
     s->is_bayer    = 0;
+    s->cur_page    = 0;
     free_geotags(s);
 
     // Reset these offsets so we can tell if they were set this frame
@@ -1393,8 +1403,20 @@  again:
             return ret;
     }
 
-    if (s->sub_ifd && s->get_subimage) {
+    /** whether we should look for this IFD's SubIFD */
+    retry_for_subifd = s->sub_ifd && s->get_subimage;
+    /** whether we should look for this multi-page IFD's next page */
+    retry_for_page = s->get_page && s->cur_page + 1 < s->get_page;  // get_page is 1-indexed
+
+    if (retry_for_page) {
+        // set offset to the next IFD
+        off = ff_tget_long(&s->gb, le);
+    } else if (retry_for_subifd) {
+        // set offset to the SubIFD
         off = s->sub_ifd;
+    }
+
+    if (retry_for_subifd || retry_for_page) {
         if (off >= UINT_MAX - 14 || avpkt->size < off + 14) {
             av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image size\n");
             return AVERROR_INVALIDDATA;
@@ -1643,6 +1665,7 @@  static av_cold int tiff_end(AVCodecContext *avctx)
 #define OFFSET(x) offsetof(TiffContext, x)
 static const AVOption tiff_options[] = {
     { "subimage", "decode subimage instead if available", OFFSET(get_subimage), AV_OPT_TYPE_BOOL, {.i64=0},  0, 1, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM },
+    { "page", "page number of multi-page image to decode (starting from 1)", OFFSET(get_page), AV_OPT_TYPE_UINT16, {.i64=0}, 0, UINT16_MAX, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM },
     { NULL },
 };