static int
JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result)
{
	if (data->bufferbytesleft==0)
	{
		uint32 m;
		if (data->filebytesleft==0)
			return(0);
		if (!data->filepositioned)
		{
			TIFFSeekFile(data->tif,data->fileoffset,SEEK_SET);
			data->filepositioned=1;
		}
		m=data->buffersize;
		if ((uint64)m>data->filebytesleft)
			m=(uint32)data->filebytesleft;
		assert(m<0x80000000UL);
		if (TIFFReadFile(data->tif,data->buffer,(tmsize_t)m)!=(tmsize_t)m)
			return(0);
		data->buffercurrentbyte=data->buffer;
		data->bufferbytesleft=m;
		data->fileoffset+=m;
		data->filebytesleft-=m;
	}
	*result=*data->buffercurrentbyte;
	data->buffercurrentbyte++;
	data->bufferbytesleft--;
	return(1);
}
['static int\nJPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16* result)\n{\n\tuint8 ma;\n\tuint8 mb;\n\tif (!JPEGFixupTagsSubsamplingReadByte(data,&ma))\n\t\treturn(0);\n\tif (!JPEGFixupTagsSubsamplingReadByte(data,&mb))\n\t\treturn(0);\n\t*result=(ma<<8)|mb;\n\treturn(1);\n}', 'static int\nJPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result)\n{\n\tif (data->bufferbytesleft==0)\n\t{\n\t\tuint32 m;\n\t\tif (data->filebytesleft==0)\n\t\t\treturn(0);\n\t\tif (!data->filepositioned)\n\t\t{\n\t\t\tTIFFSeekFile(data->tif,data->fileoffset,SEEK_SET);\n\t\t\tdata->filepositioned=1;\n\t\t}\n\t\tm=data->buffersize;\n\t\tif ((uint64)m>data->filebytesleft)\n\t\t\tm=(uint32)data->filebytesleft;\n\t\tassert(m<0x80000000UL);\n\t\tif (TIFFReadFile(data->tif,data->buffer,(tmsize_t)m)!=(tmsize_t)m)\n\t\t\treturn(0);\n\t\tdata->buffercurrentbyte=data->buffer;\n\t\tdata->bufferbytesleft=m;\n\t\tdata->fileoffset+=m;\n\t\tdata->filebytesleft-=m;\n\t}\n\t*result=*data->buffercurrentbyte;\n\tdata->buffercurrentbyte++;\n\tdata->bufferbytesleft--;\n\treturn(1);\n}']